Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JS API: Is there a way to pass data between dialog.open() and dialog.on("open")? #323

Closed
ZerdoX-x opened this issue Mar 23, 2022 · 3 comments · Fixed by #326
Closed

JS API: Is there a way to pass data between dialog.open() and dialog.on("open")? #323

ZerdoX-x opened this issue Mar 23, 2022 · 3 comments · Fixed by #326

Comments

@ZerdoX-x
Copy link
Contributor

Why open and hide methods can't accept CustomEvent rather than Event?

Problematic example:
Implementing wrapper that will two-way bind dialog's state with URLSearchParams

// Some button component JS code
dialog.show({
  detail: {
    URLSearchParamKey: "fruit",
    URLSearchParamValue: "apple",
  },
});

// some dialog with fruits
let fruitToDisplay;
dialog.on("show", function(element, { detail }) {
  fruitToDisplay = detail.URLSearchParamValue;
  URLSearchParamsRouterHelper.set($page, detail.URLSearchParamKey, fruitToDisplay);
})
render(`<Dialog>${fruitToDisplay}</Dialog>`)
@KittyGiraudel
Copy link
Owner

Hello.

Looking at the code, this should work. What problem did you encounter?

@ZerdoX-x
Copy link
Contributor Author

ZerdoX-x commented Mar 24, 2022

Hi @KittyGiraudel.

If this code should work then typing is wrong.
Event type can't have detail property as it's CustomEvent property

* @param {Event} event
* @return {this}
*/
A11yDialog.prototype.show = function (event) {

a11y-dialog/a11y-dialog.js

Lines 111 to 114 in bc5cd77

* @param {Event} event
* @return {this}
*/
A11yDialog.prototype.hide = function (event) {

image

@KittyGiraudel
Copy link
Owner

I see! Then I guess it should just be a matter of updating the typing. Do you want to give that a spin? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants