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

Fixes #5959 - jquery-bootstrap example uses handleHidden which does not exist #5961

Merged
merged 1 commit into from
Feb 2, 2016

Conversation

MarkMurphy
Copy link
Contributor

Fixes #5959. I've fixed this by adding a hook into the modal's hidden.bs.modal event.

},
componentWillUnmount: function() {
$(this.refs.root).off('hidden', this.handleHidden);
$(this.refs.root).off('hidden.bs.modal', this.handleHidden);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super familiar with this code, why did this line change? That is to say: what is the difference between hidden and hidden.bs.modal, and how do we know which one is correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hidden wasn't working for me. I checked the Bootstrap docs which shows to use hidden.bs.model and that did work for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it may not have been working because there was no listener in place for either event ie.

$(this.refs.root).on('hidden.bs.modal', this.handleHidden);
// or
$(this.refs.root).on('hidden', this.handleHidden);

I added that listener on line 25

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, both event names work. The syntax is how jQuery namespaces events. So it wasn't working for me initially because there wasn't an event listener setup when the component was mounted.

@facebook-github-bot
Copy link

@MarkMurphy updated the pull request.

1 similar comment
@facebook-github-bot
Copy link

@MarkMurphy updated the pull request.

@MarkMurphy MarkMurphy changed the title Fixes #5959 - jquery-bootstrap example uses which does not exist Fixes #5959 - jquery-bootstrap example uses handleHidden which does not exist Feb 2, 2016
@jimfb
Copy link
Contributor

jimfb commented Feb 2, 2016

Another kind of dumb question: what do I need to do to hide the modal? I tried clicking the X and tried clicking outside the modal box, neither seemed to trigger this code path.

@jimfb
Copy link
Contributor

jimfb commented Feb 2, 2016

I'm starting to think that we don't need the hide logic at all. We could probably solve this entire issue by just deleting the line $(this.refs.root).off('hidden', this.handleHidden);

I'm not convinced it really adds anything to the example (beyond what's already there; we already handle a couple of different callbacks).

@MarkMurphy
Copy link
Contributor Author

@jimfb I was wrong to remove the event namespaces...we do need them for it to work properly.

We could probably solve this entire issue by just deleting the line $(this.refs.root).off('hidden', this.handleHidden);

I actually like having the example in there. There are other events people might want to hook into so showing them how they can do that is worth making this work. I'll push another update.

@facebook-github-bot
Copy link

@MarkMurphy updated the pull request.

@MarkMurphy
Copy link
Contributor Author

@jimfb If the modal doesn't disappear when you hit ok that's very strange...

There's a native confirmation prompt that's supposed to interrupt the dismissal on the modal if you click on either the X or the Cancel buttons but it should close if you hit ok (in the confirmation or the modal)

@jimfb
Copy link
Contributor

jimfb commented Feb 2, 2016

Ok, this appears to work. Can you squash into a single commit (git rebase -i, git push -f)?

1. Add a handleHidden method to the BootstrapModal component.
2. Add an event listener for 'hidden.bs.modal' on the modal root
3. Add a new onHidden prop to the BootstrapModal component.
4. Add a new 'handleModalDidClose' method to the Example component to be used as the onHidden prop of it's modal component.
@MarkMurphy
Copy link
Contributor Author

@jimfb done.

@jimfb jimfb self-assigned this Feb 2, 2016
jimfb added a commit that referenced this pull request Feb 2, 2016
Fixes #5959 - jquery-bootstrap example uses handleHidden which does not exist
@jimfb jimfb merged commit 292f2b7 into facebook:master Feb 2, 2016
@jimfb
Copy link
Contributor

jimfb commented Feb 2, 2016

Thanks @MarkMurphy!

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

Successfully merging this pull request may close these issues.

jquery-bootstrap example uses handleHidden which does not exist
3 participants