frend / frend.co

Frend — A collection of accessible, modern front-end components.
http://frend.co
MIT License
635 stars 25 forks source link

Open the dialog automatically #109

Open acespace90 opened 6 years ago

acespace90 commented 6 years ago

Hi, is it possibile to open the dialog for example at document.ready? So without clicking on a button.

Am I wrong or that method is missing?

adamduncan commented 6 years ago

Hi @acespace90. Unfortunately the _showModal method is private. This is one of those wish we made a few more methods public in v1 things.

It's possible to show a modal by default, but requires a fair bit of mucking around with attributes/events. Here's a quick demo I've put together: https://codepen.io/adamduncan/pen/YvrYZp

It lacks a few a11y concerns (focus trap, ESC key binding, returning focus somewhere on close) and niceties (unbinding close events).

Given it's not properly accessible (in the same way one opened by a user clicking on a button), I'd maybe suggest using an alternative plugin, which exposes the events you need. E.g. a11y-dialog is great 👌

acespace90 commented 6 years ago

Ok thank you @adamduncan, hope to see that method public in the a soon future ;-)