Skip to content

Commit

Permalink
WIP: add missing modifierClick avoid preventDefault to links
Browse files Browse the repository at this point in the history
TODO: tests (possibly something global that cmd-clicks on every link and shows the DOM didn't change?)
  • Loading branch information
Haroenv committed Jan 12, 2024
1 parent 305ed20 commit 0eed703
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { cx } from '@algolia/ui-components-shared';
import { h } from 'preact';

import { isSpecialClick } from '../../lib/utils';
import Template from '../Template/Template';

import type { BreadcrumbConnectorParamsItem } from '../../connectors/breadcrumb/connectBreadcrumb';
Expand Down Expand Up @@ -86,6 +87,9 @@ const Breadcrumb = ({
className={cssClasses.link}
href={createURL(item.value)}
onClick={(event) => {
if (isSpecialClick(event)) {
return;
}
event.preventDefault();
refine(item.value);
}}
Expand Down
4 changes: 4 additions & 0 deletions packages/react-instantsearch/src/ui/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';

import { cx } from './lib/cx';
import { isModifierClick } from './lib/isModifierClick';
import { ShowMoreButton } from './ShowMoreButton';

import type { ShowMoreButtonTranslations } from './ShowMoreButton';
Expand Down Expand Up @@ -102,6 +103,9 @@ export function Menu({
className={cx('ais-Menu-link', classNames.link)}
href={createURL(item.value)}
onClick={(event) => {
if (isModifierClick(event)) {
return;
}
event.preventDefault();
onRefine(item);
}}
Expand Down

0 comments on commit 0eed703

Please sign in to comment.