Repository navigation
Conversation
Pass stable extensions and onChange to CodeMirror so re-renders no longer reconfigure the editor, which dropped the lazily added search state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the panel was lost because @uiw/react-codemirror's useCodeMirror effect reconfigures the editor whenever extensions or onChange change identity, and StateEffect.reconfigure discards the lazily appended search state. Stabilizing both identities fixes the cause rather than papering over the symptom.
Reviewed changes
- Stable
extensions—[shopify.jsonc(), policyLinter, lintGutter()]is hoisted to a module-leveleditorExtensionsarray declared afterpolicyLinter, so its identity no longer changes per render. - Stable
onChange—<CodeMirror>now receivesprops.onChangedirectly instead of an inline wrapper. The sole caller issetCodePolicy(auseStatesetter) atapp/routes/acls/overview.tsx:195, so the identity is stable in practice; the extraViewUpdateargument CodeMirror passes is simply ignored by the setter. - Changelog — one prose line under
# Next→## Fixes, correctly linked to #698.
Verified against the installed library: the reconfigure effect's remaining deps (theme, minHeight, maxHeight, editable, readOnly, basicSetup primitives) are all module constants or stable values here, so typing, a replace, and background revalidation no longer reconfigure. The omitted Differ work is correctly scoped out — react-codemirror-merge defaults destroyRerender to true and its Original/Modified children dispatch new store objects on every render, so hoisting jsonc alone genuinely would not help. oxlint and oxfmt --check are clean on both touched files.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Closes #698
The search panel in the policy file editor closed on every re-render of
Editor: after a single replace, while typing, or when the page revalidated in the background.Cause
Editorpassed a newextensionsarray and a new inlineonChangefunction to<CodeMirror>on every render.@uiw/react-codemirrordispatchesStateEffect.reconfigurewhenever either changes identity. CodeMirror adds the search state lazily viaStateEffect.appendConfigwhen the panel opens, so each reconfigure dropped it and closed the panel.Fix
props.onChange(setCodePolicy) through directly.This implements steps 1 (for
Editor), 2, and 4 of the plan in #698. Passingprops.onChangedirectly is equivalent to the suggesteduseCallbackwrapper, without the extra hook. I left out theDifferchange:react-codemirror-mergerebuilds the merge view whenever itsOriginal/Modifiedprops change, which happens on every render, so hoistingjsoncthere wouldn't help.Testing
No automated test, since the repo has no DOM/component test setup. Locally, I mounted the real
Editorin a standalone Vite page and drove it with Playwright in Firefox, simulating background revalidation by re-rendering the parent:Typecheck, lint, and unit tests pass. Also verified by hand in the running app (Firefox on macOS).
I left out the optional
search()hardening (step 3); happy to add it if preferred.🤖 Generated with help from Claude Code (Opus 5.5)