Skip to content

Commit

Permalink
Fix user menu bug with safari
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLares committed Nov 12, 2024
1 parent b425957 commit 3b243a2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions webui/src/components/user.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,25 @@ export const NavbarUser = React.createClass({
);
},

handleClick(e) {
if (this.state.open) {
this.setState({open: false})
} else {
// This is required for Safari to open the menu
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#clicking_and_focus
e.target.focus()
this.setState({open: true})
}
},

renderUser(user) {
return (
<FocusManager
onFocus={() => this.setState({open: true})}
onBlur={() => this.setState({open: false})}
>
{bind => (
<li className={"dropdown"+(this.state.open ? " open":"")}>
<a id="dropdown-top" href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" {...bind}>
<a id="dropdown-top" href="#" className="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false" onClick={(e) => this.handleClick(e)} {...bind}>
<i className="glyphicon glyphicon-user"></i>
{" "} {user.get('name')} {" "}
<span className="caret"></span>
Expand Down

0 comments on commit 3b243a2

Please sign in to comment.