Skip to content

Commit

Permalink
Fix suggestion popup flakiness (#27)
Browse files Browse the repository at this point in the history
* Fix popup by delaying display on mouse event

Fix suggested by https://discord.com/channels/686053708261228577/840286264964022302/945723974678097991

* Bump up version
  • Loading branch information
hadynz authored Feb 24, 2022
1 parent 3f01078 commit c6184be
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "obsidian-sidekick",
"name": "Sidekick",
"description": "A companion to identify hidden connections that match your tags and pages",
"version": "1.4.2",
"version": "1.4.3",
"minAppVersion": "0.13.8",
"author": "Hady Osman",
"authorUrl": "https://hady.geek.nz",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-sidekick",
"version": "1.4.2",
"version": "1.4.3",
"description": "A companion to identify hidden connections that match your tags and pages",
"main": "src/index.ts",
"repository": {
Expand Down
22 changes: 12 additions & 10 deletions src/components/suggestionsPopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ const item = (icon, title, click) => {
export const showSuggestionsModal = (props: SuggestionsModalProps): void => {
const { app, mouseEvent, suggestions, onClick } = props;

const menu = new Menu(app);
setTimeout(() => {
const menu = new Menu(app);

suggestions.forEach((replaceText) => {
menu.addItem(
item('pencil', `Replace with ${replaceText}`, () => {
onClick(replaceText);
})
);
});
suggestions.forEach((replaceText) => {
menu.addItem(
item('pencil', `Replace with ${replaceText}`, () => {
onClick(replaceText);
})
);
});

menu.addSeparator();
menu.showAtMouseEvent(mouseEvent);
menu.addSeparator();
menu.showAtMouseEvent(mouseEvent);
}, 100);
};
1 change: 1 addition & 0 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const config: Configuration = {
'@codemirror/view': 'commonjs2 @codemirror/view',
'@codemirror/state': 'commonjs2 @codemirror/state',
'@codemirror/rangeset': 'commonjs2 @codemirror/rangeset',
'webworker-threads': 'require(webworker-threads)',
},
};

Expand Down

0 comments on commit c6184be

Please sign in to comment.