Skip to content
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

Merged
merged 5 commits into from
Jan 4, 2019

Conversation

ConradJChan
Copy link
Contributor

@ConradJChan ConradJChan commented Jan 3, 2019

Introduce isOpen state in sidebar in order to persist toggle state when navigating across different files

@ConradJChan ConradJChan requested a review from a team as a code owner January 3, 2019 00:25
@boxcla
Copy link

boxcla commented Jan 3, 2019

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) {

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?

Copy link
Contributor Author

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?

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 };

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?

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the issue?

Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor

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;

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.

Copy link
Contributor

@priyajeet priyajeet Jan 3, 2019

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).

Copy link
Contributor Author

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

@priyajeet
Copy link
Contributor

@ConradJChan for UX testing, I listed the use cases here in the PR message
#658

@ConradJChan
Copy link
Contributor Author

Thanks @priyajeet, I've run through the use cases and it seems to be in order

@priyajeet
Copy link
Contributor

Can you update PR message and description

@ConradJChan ConradJChan changed the title fix(sidebar): isOpen state fix(sidebar): Maintain toggle state across file navigation Jan 4, 2019
@ConradJChan ConradJChan merged commit 0a71540 into box:master Jan 4, 2019
@ConradJChan ConradJChan deleted the activity-pane-state branch January 4, 2019 17:40
@pramodsum
Copy link
Contributor

🎉 This PR is included in version 8.9.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants