Skip to content

Commit

Permalink
Desktop: Fixes laurent22#9970: focus is lost when the hyperlink modal…
Browse files Browse the repository at this point in the history
… is cancelled

When closing the hyperlink prompt dialog, either by clicking cancel or just
by pressing escape, the prompt function returns a promise that is never
resolved or rejected, hence not executing the following code which would
give back focus to the editor.

This behaviour happens because the smalltalk library checks for a cancel
option. If this option is false or undefined (which was always the case),
the promise that is returned is never cancelled/rejected. What I did was
set this option to true so that the promise can be rejected and therefore
continue the flow of execution.

Signed-off-by: Fabio Neto <fabiogvdneto@tecnico.ulisboa.pt>
  • Loading branch information
fabiogvdneto committed Apr 3, 2024
1 parent 1e6cc11 commit e266dd8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions packages/app-desktop/gui/dialogs.ts
Expand Up @@ -21,14 +21,12 @@ class Dialogs {
}
}

public async prompt(message: string, title = '', defaultValue = '', options: any = null) {
if (options === null) options = {};

public async prompt(message: string, title = '', defaultValue = '', options: any = { cancel: true }) {
try {
const answer = await smalltalk.prompt(title, message, defaultValue, options);
return answer;
} catch (error) {
logger.error(error);
// dialog was cancelled
return null;
}
}
Expand Down

0 comments on commit e266dd8

Please sign in to comment.