Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(type_widgets): code background leaking when switching types
Elian Doranb36ef545078d
diff --git a/apps/client/src/widgets/containers/scrolling_container.css b/apps/client/src/widgets/containers/scrolling_container.cssnew file mode 100644index 0000000000..491b8a5639--- /dev/null+++ b/apps/client/src/widgets/containers/scrolling_container.css@@ -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);+}\ No newline at end of filediff --git a/apps/client/src/widgets/containers/scrolling_container.ts b/apps/client/src/widgets/containers/scrolling_container.tsindex fab51254ca..c6b67724f2 100644--- a/apps/client/src/widgets/containers/scrolling_container.ts+++ b/apps/client/src/widgets/containers/scrolling_container.ts@@ -2,6 +2,7 @@ import type { CommandListenerData, EventData, EventNames } from "../../componentimport type NoteContext from "../../components/note_context.js";import type BasicWidget from "../basic_widget.js";import Container from "./container.js";+import "./scrolling_container.css";export default class ScrollingContainer extends Container<BasicWidget> {@@ -11,9 +12,6 @@ export default class ScrollingContainer extends Container<BasicWidget> {super();this.class("scrolling-container");- this.css("overflow", "auto");- this.css("scroll-behavior", "smooth");- this.css("position", "relative");}setNoteContextEvent({ noteContext }: EventData<"setNoteContext">) {diff --git a/apps/client/src/widgets/type_widgets/code/Code.tsx b/apps/client/src/widgets/type_widgets/code/Code.tsxindex 0cbba25ea9..0b6558f7b3 100644--- a/apps/client/src/widgets/type_widgets/code/Code.tsx+++ b/apps/client/src/widgets/type_widgets/code/Code.tsx@@ -144,10 +144,7 @@ export function CodeEditor({ parentComponent, ntxId, containerRef: externalContaconst [ backgroundColor, setBackgroundColor ] = useState<string>();useEffect(() => {if (!backgroundColor || noBackgroundChange) return;- parentComponent?.$widget.closest(".scrolling-container").css("background-color", backgroundColor);- return () => {- parentComponent?.$widget.closest(".scrolling-container").css("background-color", "unset");- };+ parentComponent?.$widget.closest(".scrolling-container").css("--code-background-color", backgroundColor);}, [ backgroundColor ]);// React to theme changes.