Steps to reproduce: - type something in the searchbox. - While the searchbox is focused, click the download button. Result: the search panel is hidden (and the focus outline removed from the searchbox); the download panel appears. - Now click on the icon to open the bookmark panel. Actual result: the bookmark panel appears and the searchbox receives focus, causing the search panel to reopen, above the bookmark panel. Expected result: clicking the bookmark panel button shouldn't open the search panel. The focus being set to the searchbox again could very well be a bug too (or the cause of the bug here). Dave, do you have suggestions for what would be a reasonable way to fix this?
I'd look at what the downloads panel is doing to change the focus. You can reproduce simply by clicking the downloads button then clicking again to hide it, the searchbar gets focused again and the popup opens. On the other hand opening the bookmarks menu doesn't defocus the searchbar but does hide the panel, closing the bookmarks menu leaves focus alone so the popup doesn't reopen. If the downloads panel behaved like the bookmarks panel that would solve this bug.
I spent some time trying to figure this out. Here are my findings: - The toolbar buttons all seem to behave slightly differently wrt. focus: - The pocket button defocuses the previously focused element and does not refocus it once it's closed. - The Hello, bookmarks, and hamburger menu buttons all preserve the focus ring around the already focused element. - The downloads button defocuses the previously focused element and refocuses it once it's closed. - If you open the bookmarks panel and then click on any other button, the bookmarks panel is closed but the other button doesn't get "clicked". - The downloads code does a bunch of stuff with focus for accessibility. https://mxr.mozilla.org/mozilla-central/source/browser/components/downloads/content/downloads.js#38 - If _focusPanel (https://mxr.mozilla.org/mozilla-central/source/browser/components/downloads/content/downloads.js#495) is not called when the panel is opened, then the previously focused element is NOT given back focus when the panel is closed. I'm not sure what the right fix to this bug is. I feel like mimicking what the bookmarks button does - if you click on another button while the panel is open, the panel is closed but the other button isn't clicked - might be a reasonable solution. In any case I think there needs to be some sort of UI indication that nothing else can be "clicked" while these panels are open - currently the hover state works even though the click doesn't go through (if that makes sense). Please let me know if I'm missing something or if you have a suggestion. :)