Skip to content

Commit f435cd5

Browse files
committed
focus the first flag reason upon opening the flag modal
1 parent cad5b21 commit f435cd5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

app/assets/javascripts/flags.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ $(() => {
5555
}
5656
});
5757

58+
QPixel.DOM?.watchClass('.js-flag-box.is-active', (target) => {
59+
const reasonInput = target.querySelector('input[name="flag-reason"]');
60+
61+
if (QPixel.DOM?.isHTMLElement(reasonInput)) {
62+
reasonInput.focus();
63+
}
64+
});
65+
5866
QPixel.DOM?.watchClass('[id^="flag-comment"].is-active', (target) => {
5967
const reasonInput = target.querySelector('.js-comment-flag-reason');
6068

61-
if (reasonInput instanceof HTMLInputElement) {
69+
if (QPixel.DOM?.isHTMLElement(reasonInput)) {
6270
reasonInput.focus();
6371
}
6472
});

0 commit comments

Comments
 (0)