diff --git a/packages/docusaurus-theme-common/src/components/Details/index.tsx b/packages/docusaurus-theme-common/src/components/Details/index.tsx index 6ba2e2012d1e..3183583986bd 100644 --- a/packages/docusaurus-theme-common/src/components/Details/index.tsx +++ b/packages/docusaurus-theme-common/src/components/Details/index.tsx @@ -50,48 +50,43 @@ const Details = ({summary, children, ...props}: DetailsProps): JSX.Element => { styles.details, {[styles.isBrowser]: isBrowser}, props.className, - )}> - {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */} -
{ - const target = e.target as HTMLElement; - // Prevent a double-click to highlight summary text - if (isInSummary(target) && e.detail > 1) { - e.preventDefault(); - } - }} - onClick={(e) => { - e.stopPropagation(); // For isolation of multiple nested details/summary - const target = e.target as HTMLElement; - const shouldToggle = - isInSummary(target) && hasParent(target, detailsRef.current!); - if (!shouldToggle) { - return; - } + )} + onMouseDown={(e) => { + const target = e.target as HTMLElement; + // Prevent a double-click to highlight summary text + if (isInSummary(target) && e.detail > 1) { e.preventDefault(); - if (collapsed) { - setCollapsed(false); - setOpen(true); - } else { - setCollapsed(true); - // setOpen(false); // Don't do this, it breaks close animation! - } - }}> - {summary} + } + }} + onClick={(e) => { + e.stopPropagation(); // For isolation of multiple nested details/summary + const target = e.target as HTMLElement; + const shouldToggle = + isInSummary(target) && hasParent(target, detailsRef.current!); + if (!shouldToggle) { + return; + } + e.preventDefault(); + if (collapsed) { + setCollapsed(false); + setOpen(true); + } else { + setCollapsed(true); + // setOpen(false); // Don't do this, it breaks close animation! + } + }}> + {summary} - { - setCollapsed(newCollapsed); - setOpen(!newCollapsed); - }}> -
{children}
-
-
+ { + setCollapsed(newCollapsed); + setOpen(!newCollapsed); + }}> +
{children}
+
); };