fix: make hint markdown link clickable (#971)

This commit is contained in:
Daniel Lautzenheiser 2023-11-07 12:20:11 -05:00 committed by GitHub
parent fb5fb68ecc
commit c8dc3d4f38
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -75,7 +75,7 @@ collections:
- label: Body - label: Body
name: body name: body
widget: markdown widget: markdown
hint: "*Main* __content__ __*goes*__ [here](example.com)." hint: "*Main* __content__ __*goes*__ [here](https://example.com/)."
- name: faq - name: faq
label: FAQ label: FAQ
folder: _faqs folder: _faqs

View File

@ -1,4 +1,4 @@
import React from 'react'; import React, { useCallback } from 'react';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import gfm from 'remark-gfm'; import gfm from 'remark-gfm';
@ -6,7 +6,7 @@ import useCursor from '@staticcms/core/lib/hooks/useCursor';
import classNames from '@staticcms/core/lib/util/classNames.util'; import classNames from '@staticcms/core/lib/util/classNames.util';
import { generateClassNames } from '@staticcms/core/lib/util/theming.util'; import { generateClassNames } from '@staticcms/core/lib/util/theming.util';
import type { FC } from 'react'; import type { FC, MouseEvent } from 'react';
import './Hint.css'; import './Hint.css';
@ -40,6 +40,10 @@ const Hint: FC<HintProps> = ({
}) => { }) => {
const finalCursor = useCursor(cursor, disabled); const finalCursor = useCursor(cursor, disabled);
const handleOnClick = useCallback((event: MouseEvent) => {
event.stopPropagation();
}, []);
return ( return (
<div <div
data-testid="hint" data-testid="hint"
@ -53,6 +57,7 @@ const Hint: FC<HintProps> = ({
variant === 'inline' && classes.inline, variant === 'inline' && classes.inline,
className, className,
)} )}
onClick={handleOnClick}
> >
<ReactMarkdown <ReactMarkdown
remarkPlugins={[gfm]} remarkPlugins={[gfm]}