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

Modal: Support configurable close behaviors #437

Closed
brsanthu opened this issue Aug 25, 2016 · 5 comments · Fixed by #440
Closed

Modal: Support configurable close behaviors #437

brsanthu opened this issue Aug 25, 2016 · 5 comments · Fixed by #440

Comments

@brsanthu
Copy link
Contributor

brsanthu commented Aug 25, 2016

Modal should support disabling hiding the modal when user clicks outside the modal. This is useful when we are dealing with complicated form and we don't want user to lose the work if they accidentally clicks outside the modal.

@brsanthu
Copy link
Contributor Author

brsanthu commented Aug 25, 2016

If I have to take a look at this, how do I go about? Can you please give me some pointers?

@levithomason
Copy link
Member

Appreciate you separating this from the other Modal issue. I'd merge this PR as well. How about:

<Modal closeOnClickOutside />
<Modal closeOnEscape />

Propose we default these to true as well.

@levithomason
Copy link
Member

First, follow the CONTRIBUTING.md to get setup and understand the basics. Then,

Modal.js

  handleHide = () => {
    debug('handleHide()')
    // Always remove all dimmer classes.
    // If the dimmer value changes while the modal is open,
    //   then removing its current value could leave cruft classes previously added.
    document.body.classList.remove('blurring', 'dimmable', 'dimmed', 'scrollable')

    // == START PR == //
    // wrap these in if conditionals based on the proposed props above
    document.removeEventListener('keydown', this.handleDocumentKeyDown)
    document.removeEventListener('click', this.handleClickOutside)
    // == END PR == //
  }

See // == START PR == // comment above. Then also add/update tests in test/modules/Modal-test.js.

@levithomason
Copy link
Member

Also, only remove the body classes if the modal actually closed.

@brsanthu
Copy link
Contributor Author

Got it. Thx.

@levithomason levithomason changed the title Modal: Support disabling the "Close on click outside of modal" Modal: Support disabling close behaviors Aug 25, 2016
@levithomason levithomason changed the title Modal: Support disabling close behaviors Modal: Support configurable close behaviors Aug 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants