matrix-org / matrix-org/matrix-widget-api

Add exitModalWidget function and string constants

Open
#8 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.