question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When click the dropdown arrow in Modal's Form element, such as the Select's dropdown icon, the Modal closed

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

3.9.2

Environment

macOS 10.13.6 Chrome(Version 68.0.3440.106 (Official Build) (64-bit)), Sarari(Version 12.0 (13606.2.11))

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  1. click the Top Up button
  2. click the Search Input and then show the SearchTable
  3. click Add to show the Add Customer Modal
  4. click the Gender Select’s dropdown arrow
  5. the Add Customer Modal is closed

What is expected?

show the gender select options, not close the Modal

What is actually happening?

the Modal is closed

Remark

image

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

6reactions
zombieJcommented, Sep 21, 2018

rc-select has the logic on arrow click which stopPropagation the click event. This is OK in react life cycle.

But this demo code use addEventListener in document. Check your code on searchTable.js:

componentDidMount() {
  document.addEventListener("click", this.handleListenClick);
}

handleContainerClick(e) {
  e.nativeEvent.stopImmediatePropagation();
}

handleListenClick() {
  this.hideTable();
}

Since in react, the handleContainerClick is stopPropagation by arrow click which is not trigger. The document only get the handleListenClick trigger makes the popup hide.

It’s little tricky to use this code since react currently addEventListener on document (But maybe not in future). The addEventListener in your code is the second listener with document so you can stopImmediatePropagation to prevent what you added listener in the componentDidMount. Also this code has another potential risk like some code really want to handle document click. The better way is move the modal out of SearchTable which only provide the Add button but use some prop function like onAddCustomer to handle this.

3reactions
duzliangcommented, Sep 20, 2018

Thanks, it’s a way to solve this issues temporary, by overriding the style of Select in antd

.ant-select-selection--single {
    pointer-events: none;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Make a Modal Box With CSS and JavaScript
A modal is a dialog box/popup window that is displayed on top of the current page: Open Modal ... Get the <span> element...
Read more >
JavaScript - Bootstrap
Bootstrap provides custom events for most plugins' unique actions. Generally, these come in an infinitive and past participle form - where the infinitive...
Read more >
How to keep focus within modal dialog? - Stack Overflow
Eligible elements being checked are all visible input controls whose HTML may be input,select,textarea,button . $(document).on('keydown', ...
Read more >
lightning-modal - documentation - Salesforce Developers
Create a modal component in response to a user action, such as clicking a button ... On close, the modal must save the...
Read more >
Dropdown | Select2 - The jQuery replacement for select boxes
on('shown.bs.modal', '.modal', function() { $(this).find ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found