Limit comment toggle querySelector call to nearest answerbox
This commit is contained in:
parent
3afa52c59e
commit
ac05489329
|
@ -1,7 +1,10 @@
|
||||||
export function commentHotkeyHandler(event: Event): void {
|
export function commentHotkeyHandler(event: Event): void {
|
||||||
const button = event.target as HTMLButtonElement;
|
const button = event.target as HTMLButtonElement;
|
||||||
const id = button.dataset.aId;
|
const id = button.dataset.aId;
|
||||||
|
const answerbox = button.closest('.answerbox');
|
||||||
|
|
||||||
document.querySelector(`#ab-comments-section-${id}`).classList.remove('d-none');
|
if (answerbox !== null) {
|
||||||
document.querySelector<HTMLElement>(`[name="ab-comment-new"][data-a-id="${id}"]`).focus();
|
answerbox.querySelector(`#ab-comments-section-${id}`).classList.toggle('d-none');
|
||||||
|
answerbox.querySelector<HTMLElement>(`[name="ab-comment-new"][data-a-id="${id}"]`).focus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
export function commentToggleHandler(event: Event): void {
|
export function commentToggleHandler(event: Event): void {
|
||||||
const button = event.target as HTMLButtonElement;
|
const button = event.target as HTMLButtonElement;
|
||||||
const id = button.dataset.aId;
|
const id = button.dataset.aId;
|
||||||
|
const answerbox = button.closest('.answerbox');
|
||||||
|
|
||||||
document.querySelector(`#ab-comments-section-${id}`).classList.toggle('d-none');
|
if (answerbox !== null) {
|
||||||
|
answerbox.querySelector(`#ab-comments-section-${id}`).classList.toggle('d-none');
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue