How can I make react-bootstrap's Dropdown open on mouse hover?

后端 未结 7 1799
-上瘾入骨i
-上瘾入骨i 2020-12-15 19:40

Ok the question is simple. I need to make the dropdown open when mouse hover rather than on click.

Currently my code is as follow.

    
7条回答
  •  爱一瞬间的悲伤
    2020-12-15 19:54

    This seems like a hacky solution, but it was the easiest way to keep my app running after updating.

    With the latest update the dropdown-menu isn't rendered until the button is clicked.

    I've been using this in my css:

    .dropdown:hover .dropdown-menu {
        display: block;
    }
    

    and added this to my component

      componentDidMount() {
        // TODO: Fix so menu renders automatically w/out click
        const hiddenNavToggle = document.getElementById('navbar__hamburger_wrapper-hidden_click')
        hiddenNavToggle.click()
        hiddenNavToggle.click()
      }
    

    I added a wrapping div with the given id just to click for this.

    I'd love to hear another solution.

提交回复
热议问题