mirror of
https://github.com/zotero/zotero.git
synced 2026-09-28 01:31:40 +00:00
citation dialog: fix unhandled click on accept button of unfocused dialog (#5113)
Fix issue where clicking accept button would not work when the dialog itself is unfocused. Add a small delay in the focus handler of the dialog to allow accept button clicks to be handled before rerunning the search. Fixes: #5110
This commit is contained in:
parent
583fbf4e95
commit
4915f1fadf
1 changed files with 7 additions and 1 deletions
|
|
@ -1543,13 +1543,19 @@ let windowLostFocusOn = 0;
|
|||
window.addEventListener("blur", () => {
|
||||
windowLostFocusOn = (new Date()).getTime();
|
||||
});
|
||||
window.addEventListener("focus", () => {
|
||||
window.addEventListener("focus", async () => {
|
||||
let now = (new Date()).getTime();
|
||||
// On linux, resizing the dialog causes the window to loose and immediately regain focus.
|
||||
// Do not run the search if the window lost focus less than 100 ms ago.
|
||||
if (Zotero.isLinux && now - windowLostFocusOn < 100) {
|
||||
return;
|
||||
}
|
||||
// Wait a moment to allow accept button click event to fire.
|
||||
// Without this, clicking accept button when the dialog is not focused
|
||||
// would refocus the dialog, run the search below,
|
||||
// which replaces accept button with the spinner and interrupts the click event.
|
||||
await Zotero.Promise.delay(100);
|
||||
if (accepted) return;
|
||||
SearchHandler.clearNonLibraryItemsCache();
|
||||
currentLayout?.search(SearchHandler.searchValue);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue