docs/solutions/logic-errors/2026-04-05-reject-suggestion-must-clear-inline-element-metadata.md
rejectSuggestion must clear inline element metadataRejecting a suggestion on a link could leave the link styled as a deletion even after the suggestion was rejected.
The visible symptom was a red link that no longer had an active suggestion card.
rejectSuggestion only cleared inline suggestion metadata from text nodes and block suggestion elements.
That missed inline elements like links, even though inline suggestion metadata can live directly on the element node. acceptSuggestion already handled that shape, so the reject path was inconsistent with the accept path.
Treat inline elements the same way as text nodes in the reject cleanup paths:
remove suggestion metadatainsert suggestion nodesThe key branch is:
if (
TextApi.isText(n) ||
(ElementApi.isElement(n) && editor.api.isInline(n))
) {
const suggestionData = getInlineSuggestionData(n as TSuggestionText);
// clear or remove matching inline suggestion metadata
}
Add regression coverage with a real inline link element, not only leaf text nodes.
These checks passed:
bun test packages/suggestion/src/lib/transforms/rejectSuggestion.spec.tsx
pnpm install
pnpm turbo build --filter=./packages/link --filter=./packages/suggestion
pnpm turbo typecheck --filter=./packages/link --filter=./packages/suggestion
pnpm lint:fix
When suggestion metadata can live on both leaf text nodes and inline elements, keep acceptSuggestion and rejectSuggestion structurally symmetric.
If a regression only shows up on rendered inline UI like links or mentions, add one test with a real inline element. Text-only coverage is not enough.