-
-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add auto-scroll to canvas elements when selected from panel #3344
Changes from all commits
eaad9f3
d36dad1
413c7bf
9268da2
a755a3d
173d3ea
d957560
58b7f82
1e08581
dbd2af8
efbc979
80dd0d8
9676ffd
703d127
1dc5912
34cc01f
3c1e6e8
c86f22b
d3399a1
9c901cd
701b6a7
718ae37
52af240
0d4ed0c
d943a64
be516bb
24e57a7
169871c
2ab76b8
5f05493
93904ba
f9f69e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,7 +142,6 @@ export default function AppCanvas({ basename, state }: AppCanvasProps) { | |
|
||
setCommandHandler(bridge.canvasCommands, 'getPageViewState', () => { | ||
invariant(appRootRef.current, 'App root not found'); | ||
|
||
let nodes = viewState.current.nodes; | ||
|
||
for (const [nodeId, nodeInfo] of Object.entries(nodes)) { | ||
|
@@ -154,6 +153,15 @@ export default function AppCanvas({ basename, state }: AppCanvasProps) { | |
return { nodes }; | ||
}); | ||
|
||
setCommandHandler(bridge.canvasCommands, 'scrollComponent', (nodeId) => { | ||
if (!nodeId) { | ||
return; | ||
} | ||
invariant(appRootRef.current, 'App root not found'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe you can also just check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just copy pasted that line for the one of the command written above, should I remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, not a big deal but I think it makes more sense to just not scroll if this ref isn't there yet. |
||
const canvasNode = appRootRef.current.querySelector(`[data-node-id='${nodeId}']`); | ||
canvasNode?.scrollIntoView({ behavior: 'instant', block: 'end', inline: 'end' }); | ||
}); | ||
|
||
setCommandHandler(bridge.canvasCommands, 'getViewCoordinates', (clientX, clientY) => { | ||
if (!appRootRef.current) { | ||
return null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just another thing I noticed, not very important either: when you call
scrollComponent
from theRenderOverlay
component you already check ifselectedNode
is defined. So I guess that we don't need to check ifnodeId
is set here?