-
Notifications
You must be signed in to change notification settings - Fork 313
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
fix(sidebar): Maintain toggle state across file navigation #731
Conversation
Verified that @ConradJChan has signed the CLA. Thanks for the pull request! |
const { fileId: prevFileId, isLarge: prevIsLarge }: Props = prevProps; | ||
const { view }: State = this.state; | ||
|
||
if (fileId !== prevFileId) { |
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.
Any reason why you're removing the variables that were here before?
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.
Mainly that it's a different function, I think. Do you see any issues with it?
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.
nope, just a difference in style. Fine by me
}); | ||
|
||
// Clone initial state to allow for state reset on new files | ||
this.state = { ...this.initialState }; | ||
this.state = { isLoading: true, isOpen: !!isLarge }; |
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.
This is fine to set since this component won't unmount while navigating, and we're ok with a reset in behavior on preview close?
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 checked with the T3 behavior and it is different from what we have in EUA, we should probably create a ticket to address this in elements and EUA. We'll probably need to expose a defaultOpen
prop and some sort of toggle callback prop so that EUA can keep track of the state across preview instances
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.
What's the issue?
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.
If you toggle close the sidebar, and then 'X' out of preview, when you preview another file, the sidebar defaults to open always in EUA, but in T3 it remembers what state it was last
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.
Worst case we just store it to session storage
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.
Or in the in-memory cache.
@@ -262,28 +237,11 @@ class ContentSidebar extends PureComponent<Props, State> { | |||
return defaultView; |
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.
What will happen if the default view is set to something like skills but there are no skills on the file? We can address that in a later change.
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.
You can get rid of the defaultView
concept completely. And remove it from props and this if block. It's a feature that no one really asked for or uses at the moment (it was never documented).
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 right, sidebar is not GA'ed nor documented, so I'll remove it then
@ConradJChan for UX testing, I listed the use cases here in the PR message |
Thanks @priyajeet, I've run through the use cases and it seems to be in order |
Can you update PR message and description |
🎉 This PR is included in version 8.9.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Introduce
isOpen
state in sidebar in order to persist toggle state when navigating across different files