Skip to content

fix(markup): correct Firefox caret height near placeholder - #1223

Open
anademi wants to merge 1 commit into
gravity-ui:mainfrom
anademi:fix/firefox-caret-size
Open

fix(markup): correct Firefox caret height near placeholder#1223
anademi wants to merge 1 commit into
gravity-ui:mainfrom
anademi:fix/firefox-caret-size

Conversation

@anademi

@anademi anademi commented Sep 10, 2026

Copy link
Copy Markdown

Fixes #1222

Summary by Sourcery

Bug Fixes:

  • Correct the Firefox caret height and alignment when it appears adjacent to a placeholder.

@sourcery-ai

sourcery-ai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR updates the CodeMirror gravity theme with a Firefox-only CSS rule that baseline-aligns a .cm-widgetBuffer adjacent to a .cm-placeholder, correcting the caret height when the caret is near placeholder content without affecting other browsers.

File-Level Changes

Change Details Files
Add a Firefox-specific caret alignment workaround for placeholders.
  • Detect Firefox using a vendor-specific feature query.
  • Align a widget buffer immediately preceding a placeholder to the text baseline.
  • Scope the workaround to the existing CodeMirror gravity theme.
packages/editor/src/markup/codemirror/gravity.ts

Assessment against linked issues

Issue Objective Addressed Explanation
#1222 Ensure the caret next to the markup placeholder has the correct editor-line height in Firefox, both before and after the placeholder is clicked.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/editor/src/markup/codemirror/gravity.ts" line_range="36-40" />
<code_context>
     '.cm-placeholder': {
         color: 'var(--g-color-text-secondary)',
     },
+    '@supports (-moz-appearance: none)': {
+        '.cm-widgetBuffer:has(+ .cm-placeholder)': {
+            verticalAlign: 'baseline',
+        },
+    },
     '.cm-content': {
</code_context>
<issue_to_address>
**issue (bug_risk):** Firefox versions before 121 accept the `-moz-appearance` feature test but do not support `:has()`, so the nested rule is discarded and the caret retains the incorrect height/alignment in those browsers.

**Triggers:** When the editor runs in Firefox 120 or older, including Firefox ESR 115.

**Suggested fix:** Use a selector supported by the minimum Firefox version, or add a fallback rule that does not depend on `:has()`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: packages/editor/src/markup/codemirror/gravity.ts:40


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment on lines +36 to +40
'@supports (-moz-appearance: none)': {
'.cm-widgetBuffer:has(+ .cm-placeholder)': {
verticalAlign: 'baseline',
},
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): Firefox versions before 121 accept the -moz-appearance feature test but do not support :has(), so the nested rule is discarded and the caret retains the incorrect height/alignment in those browsers.

Triggers: When the editor runs in Firefox 120 or older, including Firefox ESR 115.

Suggested fix: Use a selector supported by the minimum Firefox version, or add a fallback rule that does not depend on :has().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect caret height next to the markup placeholder in Firefox

1 participant