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

Add support for <dialog> tag. #2033

Merged
merged 2 commits into from
Sep 3, 2014
Merged

Add support for <dialog> tag. #2033

merged 2 commits into from
Sep 3, 2014

Conversation

pekim
Copy link
Contributor

@pekim pekim commented Aug 12, 2014

fixes #2017

@zpao
Copy link
Member

zpao commented Aug 12, 2014

Thanks :) I may have oversimplified just a bit in the other issue - I didn't look closely at what was involved with dialogs.

How does one use a <dialog> in a React world? Looks like we might want to add support for the open attribute as well (according to MDN anyway). Otherwise it looks like it has to be via refs + getDOMNode.

We don't have tests for our actual supported elements but for things like this it would be good to paste some sample code here (or in a gist) or just describe how you made sure this worked in React.

@pekim
Copy link
Contributor Author

pekim commented Aug 12, 2014

Ah, I hadn't spotted the open attribute.
I have been using it along these lines.

var Credentials = React.createClass({
  componentDidMount: function() {
    this.getDOMNode().showModal();
  },

  onKeyUp: function(event) {
    if (event.keyCode === keycode.ENTER) {
      this.getDOMNode().close();
      // call a parent function...
    }
  },

  render: function() {
    return (
      <dialog className="...">
        <h2>...</h2>

        <form>
          <section>
            ...
          </section>
        </form>
      </dialog>
    );
  }
});

I'll take a closer look at the spec for anything else that I may have missed.

@pierluigi
Copy link

@pekim did you have any success making it work with the dialog polyfill ?

@pekim
Copy link
Contributor Author

pekim commented Aug 31, 2014

The <dialog> tag's only attribute seems to be open. I've add support for it, and checked that using it has the expected effect of opening the dialog without having to call the show or showModal functions.

@pekim
Copy link
Contributor Author

pekim commented Aug 31, 2014

@pierlo-upitup I'm afraid that I've not used the polyfill. I've been using <dialog> with Chrome's native support (which is good enough for me as I'm using it in a Chrome package app, and therefore know that it'll be supported).

I think of any reason it wouldn't work with the polyfill, subject to it's documented limitations (such as the <dialog> having to be a child of <body>).

@pierluigi
Copy link

@pekim in the end it was just that I wasn't registering the polyfill before using it dialogPolyfill.registerDialog(dialog); (duh). Thanks anyway!

@zpao zpao self-assigned this Sep 2, 2014
zpao added a commit that referenced this pull request Sep 3, 2014
Add support for <dialog> tag.
@zpao zpao merged commit 1854e8a into facebook:master Sep 3, 2014
@zpao
Copy link
Member

zpao commented Sep 3, 2014

Thanks!

@zpao zpao mentioned this pull request Sep 3, 2014
4 tasks
zpao added a commit that referenced this pull request Sep 16, 2014
Add support for <dialog> tag.
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 this pull request may close these issues.

No support for <dialog> tag.
3 participants