matrix-widget-api
matrix-widget-api copied to clipboard
Add exitModalWidget function and string constants
Is your feature request related to a problem? Please describe.
We have a cancel button in our modal that is basically doing the same as the "x" in the upper right corner of the modal. We want to use the same code that is running when the "x" is clicked to get the exact same result data in our CloseModalWidget
event.
Describe the solution you'd like Currently we just duplicated some logic and extended the WidgetApi with a function.
widgetApi.exitModalWidget = () => widgetApi.closeModalWidget({ "m.exited": true });
It would be nice if the exit function that is used by the "x" could be used instead. It would also be good to have constants for magic strings like m.exited
.
Another small feature request is to have a function that basically does (widgetAction: WidgetApiToWidgetAction) => `action:${widgetAction}`;
instead of writing code like this const actionButtonClicked = `action:${WidgetApiToWidgetAction.ButtonClicked}`;
to get the correct event handler name as expected by the API.
If you are ok with this I could provide a PR.