Skip to content

Commit

Permalink
fix: broken linkify
Browse files Browse the repository at this point in the history
fixes #1655
  • Loading branch information
RomanHotsiy committed Jul 1, 2021
1 parent f944da0 commit 3df72fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/common-elements/linkify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const isModifiedEvent = (event) =>
export function Link(props: { to: string; className?: string; children?: any }) {
const store = React.useContext(StoreContext);
const clickHandler = React.useCallback(
(event) => {
(event: React.MouseEvent<HTMLAnchorElement>) => {
if (!store) return;
navigate(store.menu.history, event);
navigate(store.menu.history, event, props.to);
},
[store],
);
Expand All @@ -60,14 +60,14 @@ export function Link(props: { to: string; className?: string; children?: any })
);
}

function navigate(history: HistoryService, event) {
function navigate(history: HistoryService, event: React.MouseEvent<HTMLAnchorElement>, to: string) {
if (
!event.defaultPrevented && // onClick prevented default
event.button === 0 && // ignore everything but left clicks
!isModifiedEvent(event) // ignore clicks with modifier keys
) {
event.preventDefault();
history.replace(this.props.to);
history.replace(to);
}
}

Expand Down

0 comments on commit 3df72fb

Please sign in to comment.