-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Implement the scroll state handling and restore #9209
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
base: develop
Are you sure you want to change the base?
Implement the scroll state handling and restore #9209
Conversation
Connected to Huly®: UBERF-11461 |
Signed-off-by: Rostislav Nagimov <[email protected]>
97452c0
to
ee1076c
Compare
|
||
console.log('[RESTORE] Waiting for two ticks for components to render...'); | ||
await tick(); | ||
await tick(); |
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.
looks like hack to me. why not one and not three? can we use more reliable way here, for example events?
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.
oh, I used same hack in old chat, it is because of <Component..>
. and the more they are nested, the longer we have to wait ticks
.
need to find a better solution
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.
I was making that based on the existing chat components says the "one tick is not enough to load chat messages"
Till this moment all other ways was not really working for me (tested something like 5-7 other solutions)
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.
Pull Request Overview
This PR implements scroll state handling by saving and restoring the scroll positions for scrollable elements when switching tabs. Key changes include:
- Introduction of a TabUiState interface to hold scroll position data.
- Addition of an updateTabUiState function to merge updated scroll state.
- Implementation of saveScrollState and restoreScrollState functions in the Workbench component.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
plugins/workbench/src/types.ts | Added TabUiState interface and updated WorkbenchTab to include uiState. |
plugins/workbench-resources/src/workbench.ts | Added updateTabUiState to update tab UI state with new scroll positions. |
plugins/workbench-resources/src/components/Workbench.svelte | Implemented functions to save and restore scroll positions on tab switch. |
Comments suppressed due to low confidence (2)
plugins/workbench-resources/src/workbench.ts:67
- Ensure that the 'tabId' parameter's type matches t._id. If 'tabId' is a Ref, comparing it directly to an identifier might lead to unexpected behavior; consider using 'tabId._id' or updating the parameter type to a string.
const tab = tabs.find(t => t._id === tabId);
plugins/workbench-resources/src/components/Workbench.svelte:297
- Verify that the value of 'tabId' (retrieved from $tabIdStore) is of the same type as t._id. If it is intended to be a string, ensure that there is no unintended wrapping or type mismatch that might cause the comparison to fail.
const tab = get(tabsStore).find((t) => t._id === tabId);
@rostislavnagimov please fix formatting issues. You can run |
Signed-off-by: Rostislav Nagimov <[email protected]>
3440939
to
36585ad
Compare
Formating fixed |
This change saves the scroll state for scrollable elements into the Tab and restores it to the same position when tab switches.