diff --git a/packages/app/src/composer/editor/editor.css b/packages/app/src/composer/editor/editor.css index 88d74d45fe3..2081b1165b4 100644 --- a/packages/app/src/composer/editor/editor.css +++ b/packages/app/src/composer/editor/editor.css @@ -2,13 +2,13 @@ content: "\200B"; } -/* Matches the 16px session title fade. The top fade only covers the editor's 16px top padding until text scrolls - under it; the mask sits on the viewport so the thumb stays solid. */ +/* Matches the 16px session title fade. The editor sets each depth from the text hidden past that edge; the mask + sits on the viewport so the thumb stays solid. */ [data-component="composer-scroll"] > .scroll-view__viewport { mask-image: linear-gradient( to bottom, transparent, - black 16px, + black var(--composer-fade-top, 0px), black calc(100% - var(--composer-fade-bottom, 0px)), transparent ); diff --git a/packages/app/src/composer/editor/editor.tsx b/packages/app/src/composer/editor/editor.tsx index 2032511ee75..c8d2b35029f 100644 --- a/packages/app/src/composer/editor/editor.tsx +++ b/packages/app/src/composer/editor/editor.tsx @@ -109,12 +109,18 @@ export function ComposerEditor(props: ComposerEditorProps) { }) } - // The bottom fade shrinks with the remaining scroll so the last line ends clear of it. - const [fadeBottom, setFadeBottom] = createSignal(0) + // Each fade is only as deep as the text hidden past its edge, so the editor's padding alone never fades the + // line being typed at max height. + const [fade, setFade] = createStore({ top: 0, bottom: 0 }) const updateScroll = () => { - if (!viewport) return - setFadeBottom(Math.min(16, Math.max(0, viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop))) + if (!viewport || !editor) return + const style = getComputedStyle(editor) + const below = viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop + setFade({ + top: Math.min(16, Math.max(0, viewport.scrollTop - parseFloat(style.paddingTop))), + bottom: Math.min(16, Math.max(0, below - parseFloat(style.paddingBottom))), + }) } onMount(() => { @@ -239,7 +245,7 @@ export function ComposerEditor(props: ComposerEditorProps) { { viewport = element