Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

fix: make hint markdown link clickable #971

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/dev-test/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ collections:
- label: Body
name: body
widget: markdown
hint: "*Main* __content__ __*goes*__ [here](example.com)."
hint: "*Main* __content__ __*goes*__ [here](https://example.com/)."
- name: faq
label: FAQ
folder: _faqs
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/components/common/field/Hint.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react';
import React, { useCallback } from 'react';
import ReactMarkdown from 'react-markdown';
import gfm from 'remark-gfm';

import useCursor from '@staticcms/core/lib/hooks/useCursor';
import classNames from '@staticcms/core/lib/util/classNames.util';
import { generateClassNames } from '@staticcms/core/lib/util/theming.util';

import type { FC } from 'react';
import type { FC, MouseEvent } from 'react';

import './Hint.css';

Expand Down Expand Up @@ -40,6 +40,10 @@
}) => {
const finalCursor = useCursor(cursor, disabled);

const handleOnClick = useCallback((event: MouseEvent) => {
event.stopPropagation();

Check warning on line 44 in packages/core/src/components/common/field/Hint.tsx

View check run for this annotation

Codecov / codecov/patch

packages/core/src/components/common/field/Hint.tsx#L43-L44

Added lines #L43 - L44 were not covered by tests
}, []);

return (
<div
data-testid="hint"
Expand All @@ -53,6 +57,7 @@
variant === 'inline' && classes.inline,
className,
)}
onClick={handleOnClick}
>
<ReactMarkdown
remarkPlugins={[gfm]}
Expand Down