Retrospring/app/javascript/retrospring/features/answerbox/comment/hotkey.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

11 lines
411 B
TypeScript
Raw Normal View History

2023-03-05 08:29:38 -08:00
export function commentHotkeyHandler(event: Event): void {
const button = event.target as HTMLButtonElement;
const id = button.dataset.aId;
const answerbox = button.closest('.answerbox');
2023-03-05 08:29:38 -08:00
if (answerbox !== null) {
answerbox.querySelector(`#ab-comments-section-${id}`).classList.toggle('d-none');
answerbox.querySelector<HTMLElement>(`[name="ab-comment-new"][data-a-id="${id}"]`).focus();
}
2023-03-05 08:29:38 -08:00
}