Skip to content

Toggling an inline format with an empty selection, then pressing Enter, emits an empty marker pair (**\n**) into the serialized markdown #367

@nick87kelly

Description

@nick87kelly

Environment

  • react-native-enriched-markdown: 0.7.0-nightly-20260529-af2d2f863
  • React Native: 0.81.5 · Expo SDK 54
  • Platform tested: iOS (Expo dev build, simulator). Android not yet tested.

Description
Toggling a single inline format (e.g. bold) while there is no selection (just a caret) starts an empty styled span. Pressing Enter immediately, without typing, splits that empty span across the paragraph boundary. Because inline emphasis can't cross a block boundary, the serializer closes and reopens it, producing an empty, meaningless marker pair in the output. It only happens on the first Enter (the empty span is consumed after that).

Steps to reproduce

  1. Render an EnrichedMarkdownTextInput, focus it (empty document, caret on first line).
  2. Call ref.toggleBold() (or tap a bold toolbar button) — no text selected.
  3. Press Return without typing anything.
  4. Read onChangeMarkdown / getMarkdown().
const ref = useRef<EnrichedMarkdownTextInputInstance>(null);
// focus, then:
ref.current?.toggleBold();
// user presses Enter
// onChangeMarkdown fires with:

Expected: "\n" (an empty bold toggle with no content should produce nothing, or just the newline).

Actual: "**\n**" — a stray open/close bold pair straddling the newline. Confirmed via getMarkdown(), so it persists into saved content. Same for the other formats: italic → "*\n*", strikethrough → "~~\n~~", underline → "_\n_", and stacked (bold+italic) → "***\n***".

Screen.Recording.2026-06-01.at.4.08.41.PM.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions