Skip to content

fix(editor): insert dynamic fields into the last focused editor - #241

Merged
priosshrsth merged 1 commit into
mainfrom
anit/dynamic-field-insert-at-header-cursor
Oct 7, 2026
Merged

priosshrsth merged 1 commit into
mainfrom
anit/dynamic-field-insert-at-header-cursor

Conversation

@priosshrsth

@priosshrsth priosshrsth commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Changes

Clicking a dynamic field in the sidebar always inserted into the body editor. With the cursor in the header heading/subheading (separate MinimalEditor instances), the field landed at the body editor's last selection instead of at the cursor. Editors now record themselves as focusedEditor on focus, and the sidebar inserts there. Reported in https://share.zight.com/01a0f9d8-7489-76f0-9a66-565710bac9bb

Testing Criteria

  • Cursor in subheading → click a dynamic field → inserted at the cursor (was: inserted into the body).
  • Cursor in body → click a dynamic field → still inserted at the cursor.
  • Tested in Chrome only. Heading not tested separately (same component as subheading).

Impact & Surface Area of Change

Look at DynamicFieldItem.tsx: falls back to the body editor if the focused editor was destroyed (e.g. segment switch remounting the header).

2026-10-07.10-50-16.mov

🤖 Generated with Claude Code

Sidebar dynamic fields always targeted the body editor, so with the cursor
in the heading/subheading the field landed at the body's stale selection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
client-home-v3 Ready Ready Preview Oct 7, 2026 5:03am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Tracks editor focus to route dynamic field inserts correctly.

The PR appears safe to merge.

What we checked:

  • Greeting editors support dynamic fields: Their extensions include AutofillFieldExt, which defines the insertion command.
  • Destroyed focused editors are skipped: The click checks isDestroyed and uses editor instead.

Summary

Dynamic fields now insert into the last focused heading, subheading, or body editor.

  • Sidebar fields now land in the editor you last focused.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Heading, subheading, or body gains focus] --> B[Store focusedEditor]
  C[User clicks a dynamic field] --> D{focusedEditor exists and is not destroyed?}
  D -->|Yes| E[Use focusedEditor]
  D -->|No| F[Use editor]
  E --> G[Focus target and insert field]
  F --> G
Loading

Reviews (1) · Last reviewed commit: "fix(editor): insert dynamic fields into ..." · Reviewed by Greptile

@priosshrsth
priosshrsth merged commit 76895fd into main Oct 7, 2026
8 checks passed
@priosshrsth priosshrsth self-assigned this Oct 7, 2026
@linear-code

linear-code Bot commented Oct 7, 2026

Copy link
Copy Markdown

OUT-4241

This branch was successfully deployed

1 active deployment
Preview — 9245b9c4 Deployed Oct 7, 2026 by vercel[bot]
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.

2 participants