refactor: redo the way focus is handled for popup

This commit is contained in:
Miodec 2023-09-25 00:13:29 +01:00
parent ff31b17687
commit 413c6d72d6
2 changed files with 3 additions and 11 deletions

View file

@ -140,7 +140,7 @@ export function resetBefore(): void {
before.customText = null;
}
export function showPopup(focus = false): void {
export function showPopup(): void {
if (Config.mode === "zen") {
Notifications.add("Practice words is unsupported in zen mode", 0);
return;
@ -152,10 +152,7 @@ export function showPopup(focus = false): void {
.css("opacity", 0)
.removeClass("hidden")
.animate({ opacity: 1 }, 100, () => {
if (focus) {
console.log("focusing");
$("#practiseWordsPopup .missed").trigger("focus");
}
$(`#${wrapperId}`).trigger("focus");
});
}
}
@ -190,11 +187,6 @@ $("#practiseWordsPopupWrapper .button").on("keypress", (e) => {
}
});
$("#practiseWordsPopupWrapper .button.both").on("focusout", (e) => {
e.preventDefault();
$("#practiseWordsPopup .missed").trigger("focus");
});
$(document).on("keydown", (event) => {
if (event.key === "Escape" && isPopupVisible(wrapperId)) {
hidePopup();

View file

@ -264,7 +264,7 @@
</div>
</div>
<div id="practiseWordsPopupWrapper" class="popupWrapper hidden">
<div id="practiseWordsPopupWrapper" class="popupWrapper hidden" tabindex="-1">
<div id="practiseWordsPopup" action="">
<div class="title">Practice words</div>
<div class="text">