Skip to content

Commit 733ebcb

Browse files
ENvironmentSetanakin_karrot
andauthored
fix(plugin-basic-ui): Fix scroll behavior of AppScreen (#626)
Co-authored-by: anakin_karrot <[email protected]>
1 parent 51ffe5c commit 733ebcb

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

.changeset/stupid-heads-refuse.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackflow/plugin-basic-ui": patch
3+
---
4+
5+
Fix scroll behavior of AppScreen by attaching refs on paperContent

extensions/plugin-basic-ui/src/components/AppScreen.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
7575
const paperRef = useRef<HTMLDivElement>(null);
7676
const edgeRef = useRef<HTMLDivElement>(null);
7777
const appBarRef = useRef<HTMLDivElement>(null);
78+
const paperContentRef = useRef<HTMLDivElement>(null);
7879

7980
const modalPresentationStyle =
8081
globalOptions.theme === "cupertino"
@@ -201,7 +202,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
201202
appBar?.onTopClick?.(e);
202203

203204
if (!e.defaultPrevented) {
204-
paperRef.current?.scroll({
205+
paperContentRef.current?.scroll({
205206
top: 0,
206207
behavior: "smooth",
207208
});
@@ -217,7 +218,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
217218
value={useMemo(
218219
() => ({
219220
scroll({ top }) {
220-
paperRef?.current?.scroll({
221+
paperContentRef?.current?.scroll({
221222
top,
222223
behavior: "smooth",
223224
});
@@ -229,7 +230,7 @@ const AppScreen: React.FC<AppScreenProps> = ({
229230
appBar: zIndexAppBar,
230231
},
231232
}),
232-
[paperRef, zIndexDim, zIndexPaper, zIndexEdge, zIndexAppBar],
233+
[paperContentRef, zIndexDim, zIndexPaper, zIndexEdge, zIndexAppBar],
233234
)}
234235
>
235236
<div
@@ -294,7 +295,12 @@ const AppScreen: React.FC<AppScreenProps> = ({
294295
data-part="paper"
295296
{...activityDataAttributes}
296297
>
297-
<div className={css.paperContent({ hasAppBar })}>{children}</div>
298+
<div
299+
ref={paperContentRef}
300+
className={css.paperContent({ hasAppBar })}
301+
>
302+
{children}
303+
</div>
298304
</div>
299305
{!activity?.isRoot &&
300306
globalOptions.theme === "cupertino" &&

0 commit comments

Comments
 (0)