Skip to content

Commit

Permalink
fix: stealfocus webview for SHIFT, CTRL + N, CTRL + P
Browse files Browse the repository at this point in the history
disable stealFocus for 400ms if dockingMode not docked

potentially fixes #2379 and fixes #2374 but anyway we need to carefully
review all stealfocus implied.
  • Loading branch information
panaC committed Nov 26, 2024
1 parent b643725 commit c5dbcf0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/renderer/reader/components/Reader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import {
setReadingLocationSaver, ttsClickEnable, ttsNext, ttsOverlayEnable, ttsPause,
ttsPlay, ttsPlaybackRate, ttsPrevious, ttsResume, ttsSkippabilityEnable, ttsSentenceDetectionEnable, TTSStateEnum,
ttsStop, ttsVoice, highlightsClickListen,
// stealFocusDisable,
stealFocusDisable,
} from "@r2-navigator-js/electron/renderer/index";
import { Locator as R2Locator } from "@r2-navigator-js/electron/common/locator";

Expand Down Expand Up @@ -1574,6 +1574,13 @@ class Reader extends React.Component<IProps, IState> {
}
return;
}

// lock focus outside webview for 400ms
if (this.props.readerConfig.readerDockingMode !== "full") {
stealFocusDisable(true);
setTimeout(() => stealFocusDisable(false), 400);
}

this.handleMenuButtonClick(true, this.state.openedSectionMenu, true);
};
private onKeyboardFocusSettings = () => {
Expand Down Expand Up @@ -2247,15 +2254,20 @@ class Reader extends React.Component<IProps, IState> {
return;
}

// // Force webview to give the hand before Radix Dialog triggered
// stealFocusDisable(true);
// lock focus outside webview for 400ms
if (this.props.readerConfig.readerDockingMode !== "full") {
stealFocusDisable(true);
setTimeout(() => stealFocusDisable(false), 400);
}

this.handleMenuButtonClick(true, "tab-toc");

setTimeout(() => {
const anchor = document.getElementById("headingFocus");
if (anchor) {
anchor.focus();
} else {
console.error("headingFocus not found !!!!!!");
}
}, 1);
}
Expand Down

0 comments on commit c5dbcf0

Please sign in to comment.