Skip to content

Commit d5658fc

Browse files
authored
Merge pull request #268 from code-hike/transition-scrollbars
Fix focus height on transitions
2 parents c0836c7 + e535588 commit d5658fc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/mdx/src/smooth-code/splitter.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,17 @@ export function splitByFocus(
8989
>
9090
): FocusedCode {
9191
const { lines, ...mergedCodeRest } = mergedCode
92-
const focusByLineNumber = map(focus, focus =>
93-
mapFocusToLineNumbers(focus, lines)
94-
)
92+
93+
const focusByLineNumber = map(focus, (focus, key) => {
94+
// we need to filter the lines that don't belong to the step
95+
// for the case where focus == ""
96+
const stepLines =
97+
key === "prev"
98+
? lines.filter(l => l.move !== "enter")
99+
: lines.filter(l => l.move !== "exit")
100+
101+
return mapFocusToLineNumbers(focus, stepLines)
102+
})
95103

96104
const splittedLines = lines.map(line => {
97105
const { tokens, ...rest } = line

0 commit comments

Comments
 (0)