Skip to content

Allow execution of client-side code in Shortcuts #23399

@probert94

Description

@probert94

Describe your motivation

In an application I am working on I have some actions that can trigger a download or open the file-chooser to upload a file.
The actions are usually displayed as buttons and trigger on click. Now I would like to add Shortcuts for those actions as well.
Right now I have to add a normal ShortcutListener and on the server-side call Button#clickInClient and it seems to work at least in Chromium and Firefox on Windows. But a while back I had problems, especially with Firefox, when opening the file-chooser using executeJs and with the popup-blocker when triggering a download from the server.
Regarding the documentation of showOpenFilePicker it requres transient user activation which might not be the case when calling it after a roundtrip.
Also the popup-blocker in case of a download seems to depend on timing as a server-side breakpoint during the roundtrip seems to trigger it even in Google Chrome.
So therefor I am a bit afraid, that the current solution might not be very stable.
Also the Shortcut executes an unneccessary roundtrip, as the server only calls a client-side function.

Describe the solution you'd like

Therefor I would like to be able to add client-side code to the Shortcutlistener, similar to what resetFocusOnActiveElement already does.
In theory everything that is required should be there already, as Shortcuts use DomListenerRegistration#setFilter under the hood which has access to element and event. So an API to add something to that filter would be enough.

Describe alternatives you've considered

Right now I am using Button#clickInClient with the mentioned drawbacks.
As the Shortcuts-API does not allow to add custom code to the filter the only other alternative I could think of is to create my own Shortcuts implementation based on DomListener.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions