Skip to content

Commit 85cabac

Browse files
committed
Refactor login/logout URL generation in BaseForm
1 parent 35ffe3f commit 85cabac

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

packages/comment-widget/src/base-form.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,15 @@ export class BaseForm extends LitElement {
7373
);
7474
}
7575

76-
get loginUrl() {
77-
const parentDomId = `#comment-${[
78-
this.group?.replaceAll('.', '-'),
79-
this.kind,
80-
this.name,
81-
]
76+
get parentDomId() {
77+
return `#comment-${[this.group?.replaceAll('.', '-'), this.kind, this.name]
8278
.join('-')
8379
.replaceAll(/-+/g, '-')}`;
80+
}
8481

82+
get loginUrl() {
8583
return `/login?redirect_uri=${encodeURIComponent(
86-
window.location.pathname + parentDomId
84+
window.location.pathname + this.parentDomId
8785
)}`;
8886
}
8987

@@ -140,7 +138,9 @@ export class BaseForm extends LitElement {
140138
)
141139
) {
142140
try {
143-
window.location.href = '/logout';
141+
window.location.href = `/logout?redirect_uri=${encodeURIComponent(
142+
window.location.pathname + this.parentDomId
143+
)}`;
144144
} catch (error) {
145145
console.error('Failed to logout', error);
146146
}
@@ -170,13 +170,6 @@ export class BaseForm extends LitElement {
170170
</div>`;
171171
}
172172

173-
onContentInput(e: Event) {
174-
const target = e.target as HTMLTextAreaElement;
175-
// reset height to auto to make sure it can grow
176-
target.style.height = 'auto';
177-
target.style.height = `${target.scrollHeight}px`;
178-
}
179-
180173
onKeydown(e: KeyboardEvent) {
181174
if (e.key === 'Enter' && (e.metaKey || e.ctrlKey)) {
182175
const form = this.shadowRoot?.querySelector('form');

0 commit comments

Comments
 (0)