From 03b24b547f81a04e5ddbe6da9a08bad1d376c835 Mon Sep 17 00:00:00 2001 From: Silas Rafael Barreto Prado Date: Tue, 23 Dec 2025 15:56:55 -0300 Subject: [PATCH 1/2] fix code mirror position and auto scroll --- src/components/B4ACodeTree/B4ACodeTree.scss | 19 ++++++++++++++++++- .../CodeEditor/B4aCodeEditor.react.js | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/B4ACodeTree/B4ACodeTree.scss b/src/components/B4ACodeTree/B4ACodeTree.scss index fc618226a6..2725035360 100644 --- a/src/components/B4ACodeTree/B4ACodeTree.scss +++ b/src/components/B4ACodeTree/B4ACodeTree.scss @@ -238,7 +238,10 @@ .filesPreviewWrapper { height: 100%; - overflow: hidden; + // Important: don't create an overflow-clipping ancestor here, otherwise + // CodeMirror's search panel (position: sticky) won't stick to the actual + // scroll container (which is higher up in the dashboard layout). + overflow: visible; .filesPreviewHeader { @include InterFont; @@ -259,6 +262,20 @@ outline: none; } } + + // Keep CodeMirror's search panel visible while scrolling the code area. + // The search panel is rendered by @codemirror/search (Ctrl/Cmd+F). + :global(.cm-panels-top) { + position: sticky; + top: 0; + z-index: 50; + background: #0A0B0C; + border-bottom: 1px solid rgba(249, 249, 249, 0.06); + } + + :global(.cm-panels-top .cm-search) { + background: #0A0B0C; + } } .folderInfoWrapper { diff --git a/src/components/CodeEditor/B4aCodeEditor.react.js b/src/components/CodeEditor/B4aCodeEditor.react.js index ae7d2fcae8..7b8eb41bb3 100644 --- a/src/components/CodeEditor/B4aCodeEditor.react.js +++ b/src/components/CodeEditor/B4aCodeEditor.react.js @@ -7,6 +7,7 @@ import { json } from '@codemirror/lang-json'; import { xml } from '@codemirror/lang-xml'; import { linter, lintGutter } from '@codemirror/lint'; import { search } from '@codemirror/search'; +import { EditorView } from '@codemirror/view'; import globals from 'globals'; import { createTheme } from '@uiw/codemirror-themes'; import { tags as t } from '@lezer/highlight'; @@ -141,7 +142,11 @@ const B4aCodeEditor = forwardRef(({ code: initialCode, onCodeChange, mode, readO extensions={[ ...getLanguageExtension(), lintGutter(), - search({ top: true}) + search({ + top: true, + // Ensure Enter/Next/Prev in the search panel scrolls the editor to the selected match. + scrollToMatch: (range) => EditorView.scrollIntoView(range.from, { y: 'center' }), + }) ]} onChange={(value) => { handleCodeChange(value) From b1f3d394602d22abdce141b3752c5b0db5e0c139 Mon Sep 17 00:00:00 2001 From: Silas Rafael Barreto Prado Date: Tue, 23 Dec 2025 16:38:47 -0300 Subject: [PATCH 2/2] update react-components dependency --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8619fd2d2a..b4527bb1e5 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@babel/runtime": "7.20.13", "@babel/runtime-corejs3": "7.20.13", "@back4app/back4app-settings": "1.6.5", - "@back4app2/react-components": "1.0.0-beta.440.30", + "@back4app2/react-components": "1.0.0-beta.440.36", "@codemirror/lang-css": "6.3.0", "@codemirror/lang-html": "6.4.9", "@codemirror/lang-javascript": "6.2.2",