React 17: Dropdown does not expand after opening/closing a modal in IE11
See original GitHub issueDescribe the bug
I am having an issue with react-bootstrap
Dropdowns/DropdownButtons in IE11. Everything seems to work fine opening and closing Dropdown buttons and menus normally. However, if you happen to have a Modal which you open and close, and then click on a Dropdown, the Dropdown will no longer open.
To Reproduce
Open a Modal. Close a Modal. Then click on a Dropdown Menu.
Example
https://github.com/perryf/react-bootstrap-bug
Dependencies
"dependencies": {
"bootstrap": "^4.6.0",
"react": "^17.0.1",
"react-app-polyfill": "^2.0.0",
"react-bootstrap": "^1.4.3",
"react-dom": "^17.0.1",
"react-scripts": "^4.0.2"
}
index.js
import 'react-app-polyfill/ie11' // For IE 11 support
import 'react-app-polyfill/stable'
import React from 'react'
import ReactDOM from 'react-dom'
import 'bootstrap/dist/css/bootstrap.min.css'
import App from './App'
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
)
App.js
import React, { useState } from 'react'
import { Button, Modal, DropdownButton, Dropdown } from 'react-bootstrap'
const App = () => {
const [showModal, setShowModal] = useState(false)
const handleClose = () => setShowModal(false)
const handleShow = () => setShowModal(true)
return (
<div>
<h1>Dropdown Test</h1>
<Button onClick={handleShow}>Open Modal</Button>
<DropdownButton
id="dropdown-test"
title="Dropdown Button"
variant="secondary"
>
<Dropdown.Item>1</Dropdown.Item>
<Dropdown.Item>2</Dropdown.Item>
<Dropdown.Item>3</Dropdown.Item>
</DropdownButton>
<Modal
animation={false}
show={showModal}
onHide={handleClose}
backdrop="static"
>
<Modal.Header>Hiya!</Modal.Header>
<Modal.Body>
<Button onClick={handleClose}>Close</Button>
</Modal.Body>
</Modal>
</div>
)
}
export default App
Environment
- Operating System: Windows 10
- Browser - IE11
- React-Bootstrap Version 4.6.0
Additional Information
After downgrading to react and react-dom to v16.14, I could then get the dropdown menus to open and close after opening/closing a modal.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
React-Bootstrap dropdown not expanding - Stack Overflow
When you click the dropdown menu item the <RootCloseWrapper> is rendered as enabled and adds event listeners for click event to close the ......
Read more >Clicking on the drop-down list of a dependent field in list view ...
In IE11, when attempting to list edit a dependent field in list view, the dependent field drop-down menu does not open. Steps to...
Read more >React Table: A complete tutorial with examples
In this React table tutorial, we'll show you how to implemenet your own data table in React using react-table, complete with examples.
Read more >Changelog for WYSIWYG Editor - Froala
Image manager buttons have an incorrect size depending on the website CSS rules. Dropdowns are not closing all the time when using the...
Read more >Stop Using 'Drop-down' - Adrian Roselli
Until recently, HTML had no equivalent to a native combobox, but the <datalist> / <option> roughly addresses that. Screen readers seem to enjoy ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It is indeed 4.1.1. Adding
onClick={(e) => e.stopPropagation(e)}
to all the dropdowns seems to work though.Adding
onClick={(e) => e.stopPropagation()}
did the trick for me in IE11 and older versions of Firefox 👍