简体   繁体   中英

Bootstrap drop down auto close not working on react

I am using the drop button of bootstrap and it works ok when clicking on it, but when I want to disable it by click outside using the

autoClose='outside'

it does not work. When I click my hamburger menu, the menu drops as expected but when I want to disable it by clicking outside it does not. This is how my code looks like

        <Dropdown onClick={preventa} autoClose='outside' className='drop'>
            <Dropdown.Toggle id="dropdown-basic" >
              <a href="/" ><GiHamburgerMenu size={40} color="#bbff00" className='hamburger' /></a> 
            </Dropdown.Toggle>
            <Dropdown.Menu>
              <Dropdown.Item href="#/action-1"><NavItems /></Dropdown.Item>
            </Dropdown.Menu>
          </Dropdown>

Where could I be going wrong

The autoClose prop of the Dropdown component in Bootstrap only works when the Dropdown.Menu is opened via a Dropdown.Toggle component (eg, a button, a link etc)

In your component you use a dropdown component to wrap an anchor element having the GiHamburgerMenu icon. The dropdown component is not being used as a toggle, so the autoClose prop won't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM