react-menu icon indicating copy to clipboard operation
react-menu copied to clipboard

When using library inside of a component the CSS is bugging after page is reloaded.

Open paoloviselli opened this issue 1 year ago • 3 comments

I am trying to use the library to generate a drop down menu from a button within a component.

Like so:

Screenshot 2022-08-03 at 16 18 41

The library is working on most cases, however if I reload the page and try to use the drop down again this happens:

Screenshot 2022-08-03 at 16 18 51

The functionality is still there (e.g. if I click on the text fields that popped up they still redirect where they are supposed to, however the css is bugged).

Anyone experienced this too or knows where the problem might be?

Here the snippet of my code where I use the Menu

Screenshot 2022-08-03 at 16 25 39

Thanks

paoloviselli avatar Aug 03 '22 13:08 paoloviselli

Hi @paoloviselli , your code looks good to me. The only issue is MenuButton wraps a Button which is not necessary. You might use Button for the menuButton prop directly. But I think this is not related to the styling bug in your code.

Are you using the default index.css that comes with the npm package? If so, is the css still applied after page is reloaded?

szhsin avatar Aug 04 '22 11:08 szhsin

Hi @szhsin I am using the default index.css however the CSS kept disappearing each time I reloaded the page. I had to install Material UI for other components and I ended up using also their Menu and the MUI Menu, used in the same exact code does not present that issue.

However the weird thing was that I was using your Menu library on another page of my project and it was not presenting this issue at all. The only difference in this use was the fact that is was not nested into any components. Might be that the problem?

Hope this helps.

paoloviselli avatar Aug 05 '22 13:08 paoloviselli

Nesting the menu into components is totally fine. You could use browser dev tools to inspect what css has been applied to menu before and after the page is reloaded.

Also, you don't have to use the index.css. The css rules in the file can be copied into your project stylesheets or CSS-in-JS solution.

szhsin avatar Aug 05 '22 14:08 szhsin