-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Dialog): prevent
onClose
event from firing in StrictMode when o…
…pening a new dialog (#4525) - Also add `handler` to `triggeredBy` when the `close` method is called. - Improve the documentation of the `triggeredBy` property. - More [info](https://dnb-it.slack.com/archives/CMXABCHEY/p1738574258572699?thread_ts=1738072824.587899&cid=CMXABCHEY) about the approach. - Thank you Ahmet for the [good reprod](https://codesandbox.io/p/sandbox/connectwithpath-forked-h2wr7p). 🫶
- Loading branch information
1 parent
1a92512
commit d24c0d3
Showing
8 changed files
with
327 additions
and
66 deletions.
There are no files selected for viewing
12 changes: 11 additions & 1 deletion
12
packages/dnb-design-system-portal/src/docs/uilib/components/modal/event-table.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
| Events | Description | | ||
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| `onOpen` / `on_open` | _(optional)_ This event gets triggered once the modal shows up. Returns the modal id: `{ id }`. | | ||
| `onClose` / `on_close` | _(optional)_ this event gets triggered once the modal gets closed. Returns the modal id: `{ id, event, triggeredBy }`. | | ||
| `onClose` / `on_close` | _(optional)_ this event gets triggered once the modal gets closed. Returns the modal id: `{ id, event, triggeredBy }`. More info about the `triggeredBy` down below. | | ||
| `onClosePrevent` / `on_close_prevent` | _(optional)_ this event gets triggered once the user tries to close the modal, but `prevent_close` is set to **true**. Returns a callback `close` you can call to trigger the close mechanism. More details below. Returns the modal id: `{ id, event, close: Method, triggeredBy }` | | ||
|
||
## `triggeredBy` | ||
|
||
The `triggeredBy` property is given when the `onClose` or the `onClosePrevent` event is triggered. It can contain one of the following values: | ||
|
||
- `button`: The close button that triggered the event. | ||
- `handler`: The `close` handler given by the function (as the content/children). | ||
- `keyboard`: The escape key that triggered the event. | ||
- `overlay`: The overlay element that triggered the event. | ||
- `unmount`: The unmount event that triggered the `openState` prop change. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.