matrix-org / matrix-org/matrix-widget-api
Add exitModalWidget function and string constants
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 95
- Forks
- 24
- Avg merge
- 16h 16m
- Merged PRs (30d)
- 1
Description
**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.
```js
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the WidgetApi, CloseModalWidget, and WidgetApiToWidgetAction definitions in the repository. Review how the modal exit action and event-handler names are currently represented, then add the requested exit function, constants for magic strings, and action-name helper. Done means callers can use these shared APIs instead of duplicating the existing logic or formatting event names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100