mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix the back/forward button on topbar (#3719)
* Check only webcontent type === 'window' instead of using webContents.getFocusedWebContents(), as other webview can capture focus Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com> * Update test Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
3 files changed
+26
-7
No files matched your search
@@ -50,11 +50,12 @@ const goForward = jest.fn();
|
||||
jest.mock("@electron/remote", () => {
|
||||
return {
|
||||
webContents: {
|
||||
getFocusedWebContents: () => {
|
||||
return {
|
||||
getAllWebContents: () => {
|
||||
return [{
|
||||
getType: () => "window",
|
||||
goBack,
|
||||
goForward
|
||||
};
|
||||
}];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -69,11 +69,11 @@ export const TopBar = observer(({ children, ...rest }: Props) => {
|
||||
};
|
||||
|
||||
const goBack = () => {
|
||||
webContents.getFocusedWebContents()?.goBack();
|
||||
webContents.getAllWebContents().find((webContent) => webContent.getType() === "window")?.goBack();
|
||||
};
|
||||
|
||||
const goForward = () => {
|
||||
webContents.getFocusedWebContents()?.goForward();
|
||||
webContents.getAllWebContents().find((webContent) => webContent.getType() === "window")?.goForward();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in new issue
Block a user