Skip to content

Commit b36ef54

Browse files
committed
fix(type_widgets): code background leaking when switching types
1 parent c772430 commit b36ef54

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.scrolling-container {
2+
overflow: auto;
3+
scroll-behavior: smooth;
4+
position: relative;
5+
}
6+
7+
.note-split.type-code > .scrolling-container {
8+
background-color: var(--code-background-color);
9+
}

apps/client/src/widgets/containers/scrolling_container.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { CommandListenerData, EventData, EventNames } from "../../component
22
import type NoteContext from "../../components/note_context.js";
33
import type BasicWidget from "../basic_widget.js";
44
import Container from "./container.js";
5+
import "./scrolling_container.css";
56

67
export default class ScrollingContainer extends Container<BasicWidget> {
78

@@ -11,9 +12,6 @@ export default class ScrollingContainer extends Container<BasicWidget> {
1112
super();
1213

1314
this.class("scrolling-container");
14-
this.css("overflow", "auto");
15-
this.css("scroll-behavior", "smooth");
16-
this.css("position", "relative");
1715
}
1816

1917
setNoteContextEvent({ noteContext }: EventData<"setNoteContext">) {

apps/client/src/widgets/type_widgets/code/Code.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,7 @@ export function CodeEditor({ parentComponent, ntxId, containerRef: externalConta
144144
const [ backgroundColor, setBackgroundColor ] = useState<string>();
145145
useEffect(() => {
146146
if (!backgroundColor || noBackgroundChange) return;
147-
parentComponent?.$widget.closest(".scrolling-container").css("background-color", backgroundColor);
148-
return () => {
149-
parentComponent?.$widget.closest(".scrolling-container").css("background-color", "unset");
150-
};
147+
parentComponent?.$widget.closest(".scrolling-container").css("--code-background-color", backgroundColor);
151148
}, [ backgroundColor ]);
152149

153150
// React to theme changes.

0 commit comments

Comments
 (0)