Skip to content

Commit

Permalink
Merge pull request #9433 from ForumMagnum/custom-onmousedown-before-m…
Browse files Browse the repository at this point in the history
…odifier-return

run custom onMouseDown logic before doing an early return for modifier keys
  • Loading branch information
b0b3rt committed Jun 20, 2024
2 parents cb7ae3d + 83f8b2b commit b8c5cc0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/lesswrong/components/common/HashLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@ export function HashLink(props: HashLinkProps) {
{...filteredProps}
href={to}
onMouseDown={(ev) => {
// Run any custom onMouseDown logic, including event tracking (such as that passed in from `Link`) before checking for modifier keys
// This is necessary to capture e.g. `linkClicked` events when cmd-clicking to open links in a new tab
filteredProps.onMouseDown?.(ev);
if (ev.metaKey || ev.altKey || ev.ctrlKey || ev.shiftKey || ev.button !== 0) {
return;
}
filteredProps.onMouseDown?.(ev)
navigate(to);
ev.preventDefault();
}}
Expand Down

0 comments on commit b8c5cc0

Please sign in to comment.