Skip to content

Commit

Permalink
Add middleclick support for service button (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
wachunei authored Aug 13, 2020
1 parent 4592008 commit dbcfc08
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/js/ui/containers/Popup/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,31 @@ const Popup = () => {
})();
}, [username]);

const handleServiceClick = async ({ target }) => {
const { service } = target.dataset;
const handleServiceClick = async (event) => {
const {
type,
button,
target: {
dataset: { service },
},
} = event;

const isMiddleClick = type === "auxclick" && button === 1;

setLoading(true);
try {
await dispatch({
type: `servicesActions.${service}.callActionAndRedirect`,
payload: {
disposition: isMiddleClick ? "newBackgroundTab" : undefined,
},
});

setLoading(false);
window.close();

if (!isMiddleClick) {
window.close();
}
} catch {
setLoading(false);
}
Expand Down Expand Up @@ -114,6 +130,7 @@ const Popup = () => {
key={key}
service={service}
onClick={handleServiceClick}
onAuxClick={handleServiceClick}
data-service={key}
title={`Abrir ${service.name}`}
// eslint-disable-next-line jsx-a11y/tabindex-no-positive
Expand Down

0 comments on commit dbcfc08

Please sign in to comment.