mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-19 00:16:05 +01:00
Limit comment toggle querySelector call to nearest answerbox
This commit is contained in:
parent
3afa52c59e
commit
ac05489329
2 changed files with 10 additions and 4 deletions
|
@ -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 a new issue