Skip to content

Commit

Permalink
Fix logout button not being tabbable
Browse files Browse the repository at this point in the history
I'm not sure why this didn't work before, as the other
"wrapperless" menuitems in language and color menu are
very much tabbable (is that a word?). Anyway this adds
a `div` wrapper with a `tabindex={0}` to make it keyboard
reachable again.
  • Loading branch information
owi92 committed Oct 16, 2023
1 parent c8dd057 commit e41ec7b
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions frontend/src/layout/header/UserBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,30 +234,33 @@ const LoggedIn: React.FC<LoggedInProps> = ({ user }) => {
}
: {
keepOpenAfterClick: true,
onClick: () => {
wrapper: <div
tabIndex={0}
onClick={() => {
// We don't do anything if a request is already pending.
if (logoutState === "pending") {
return;
}
if (logoutState === "pending") {
return;
}

setLogoutState("pending");
fetch("/~session", { method: "DELETE" })
.then(() => {
setLogoutState("pending");
fetch("/~session", { method: "DELETE" })
.then(() => {
// We deliberately ignore the `status`. See `handle_logout`
// for more information.
//
// We hard forward to the home page to get rid of any stale state.
window.location.href = "/";
})
.catch(error => {
window.location.href = "/";
})
.catch(error => {
// TODO: this is not great. It should happen only
// extremely rarely, but still, just showing a triangle
// is not very great for the user.
// eslint-disable-next-line no-console
console.error("Error during logout: ", error);
setLogoutState("error");
});
},
console.error("Error during logout: ", error);
setLogoutState("error");
});
}}
/>,
},
},
];
Expand Down

0 comments on commit e41ec7b

Please sign in to comment.