fix(type_widgets): code background leaking when switching types

This commit is contained in:
Elian Doran 2025-11-09 13:37:31 +02:00
parent c772430dd0
commit b36ef54507
No known key found for this signature in database
3 changed files with 11 additions and 7 deletions

View File

@ -0,0 +1,9 @@
.scrolling-container {
overflow: auto;
scroll-behavior: smooth;
position: relative;
}
.note-split.type-code > .scrolling-container {
background-color: var(--code-background-color);
}

View File

@ -2,6 +2,7 @@ import type { CommandListenerData, EventData, EventNames } from "../../component
import type NoteContext from "../../components/note_context.js"; import type NoteContext from "../../components/note_context.js";
import type BasicWidget from "../basic_widget.js"; import type BasicWidget from "../basic_widget.js";
import Container from "./container.js"; import Container from "./container.js";
import "./scrolling_container.css";
export default class ScrollingContainer extends Container<BasicWidget> { export default class ScrollingContainer extends Container<BasicWidget> {
@ -11,9 +12,6 @@ export default class ScrollingContainer extends Container<BasicWidget> {
super(); super();
this.class("scrolling-container"); this.class("scrolling-container");
this.css("overflow", "auto");
this.css("scroll-behavior", "smooth");
this.css("position", "relative");
} }
setNoteContextEvent({ noteContext }: EventData<"setNoteContext">) { setNoteContextEvent({ noteContext }: EventData<"setNoteContext">) {

View File

@ -144,10 +144,7 @@ export function CodeEditor({ parentComponent, ntxId, containerRef: externalConta
const [ backgroundColor, setBackgroundColor ] = useState<string>(); const [ backgroundColor, setBackgroundColor ] = useState<string>();
useEffect(() => { useEffect(() => {
if (!backgroundColor || noBackgroundChange) return; if (!backgroundColor || noBackgroundChange) return;
parentComponent?.$widget.closest(".scrolling-container").css("background-color", backgroundColor); parentComponent?.$widget.closest(".scrolling-container").css("--code-background-color", backgroundColor);
return () => {
parentComponent?.$widget.closest(".scrolling-container").css("background-color", "unset");
};
}, [ backgroundColor ]); }, [ backgroundColor ]);
// React to theme changes. // React to theme changes.