Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
fix: apply back/forward to correct pane
Browse files Browse the repository at this point in the history
In multi-pane conditions it used to apply the back/forward actions to
the former active pane.
  • Loading branch information
kometenstaub committed Mar 28, 2022
1 parent 24e4076 commit 85b9f50
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "cross-env BUILD=production node esbuild.mjs",
"release": "standard-version",
"format": "npx prettier --write src/",
"css": "npx sass --watch src/styles.scss build/styles.css"
"css": "npx sass --watch src/styles.scss build/styles.css"
},
"standard-version": {
"t": "",
Expand All @@ -35,12 +35,11 @@
"author": "kometenstaub",
"license": "MIT",
"devDependencies": {
"@types/feather-icons": "^4.7.0",
"@types/node": "^14.14.37",
"cross-env": "^7.0.3",
"css-minify": "^2.0.0",
"esbuild": "0.14.3",
"obsidian": "^0.13.30",
"obsidian": "^0.14.3",
"prettier": "2.5.1",
"sass": "^1.49.9",
"standard-version": "^9.3.2",
Expand Down
21 changes: 18 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,24 @@ export default class TopBarButtonsPlugin extends Plugin {

viewActions.prepend(buttonIcon);

this.registerDomEvent(buttonIcon, 'click', () => {
this.app.commands.executeCommandById(id);
});
if (
this.settings.paneRelief &&
(id === 'app:go-forward' || id === 'app:go-back')
) {
this.registerDomEvent(buttonIcon, 'click', () => {
/* this way the pane gets activated from the click
otherwise the action would get executed on the former active pane
timeout of 1 was enough, but 5 is chosen for slower computers
may need to be made its own setting in the future
*/
setTimeout(() => this.app.commands.executeCommandById(id), 5)
});

} else {
this.registerDomEvent(buttonIcon, 'click', () => {
this.app.commands.executeCommandById(id);
});
}
}

addLeftTitleBarButton(viewActions: Element, button: baseButton) {
Expand Down

0 comments on commit 85b9f50

Please sign in to comment.