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

[Popup] We need a JS method to open the popup #471

Closed
mfreed7 opened this issue Feb 24, 2022 · 2 comments
Closed

[Popup] We need a JS method to open the popup #471

mfreed7 opened this issue Feb 24, 2022 · 2 comments
Labels
popover The Popover API

Comments

@mfreed7
Copy link
Collaborator

mfreed7 commented Feb 24, 2022

Given the new approach for popup, and the associated resolution not to have a "live" open content attribute, there needs to be a way to open/reopen the popup via Javascript. The most straightforward would seem to be something like:

const myPopup = document.querySelector('div[popup]');
myPopup.show(); // or
myPopup.showPopup();

That would require adding a show() or showPopup() IDL method to HTMLElement. And then the question becomes: what happens if this is called on an element that lacks the popup attribute? Or for which the value of the popup attribute is invalid? I think it likely should do nothing, but it could also throw, and it could also add a valid popup attribute to the element. The last one feels odd, but I suppose it's an option.

@mfreed7
Copy link
Collaborator Author

mfreed7 commented Feb 24, 2022

I should have added, we also need a corresponding way to close the popup from Javascript:

myPopup.hide(); // or
myPopup.hidePopup();

That one likely should not throw and should not change any attributes. It should just be a no-op if the element isn't currently a top layer popup.

@gregwhitworth gregwhitworth added the popover The Popover API label Feb 25, 2022
@mfreed7
Copy link
Collaborator Author

mfreed7 commented Mar 24, 2022

This has been added to the explainer, here.

const popup = document.querySelector('[popup]');
popup.showPopup(); // Show the popup
popup.hidePopup(); // Hide a visible popup

@mfreed7 mfreed7 closed this as completed Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
popover The Popover API
Projects
None yet
Development

No branches or pull requests

2 participants