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

[docs]: fix the RightPanel to work correctly with browser history. #1166

Closed
wants to merge 1 commit into from
Closed

[docs]: fix the RightPanel to work correctly with browser history. #1166

wants to merge 1 commit into from

Conversation

nisarhassan12
Copy link
Contributor

Fixes #1140

@nisarhassan12 nisarhassan12 marked this pull request as ready for review April 18, 2020 18:16
@jorgeorpinel jorgeorpinel temporarily deployed to dvc-landing-right-panel-a8guvo April 18, 2020 19:48 Inactive
@shcheklein shcheklein temporarily deployed to dvc-landing-right-panel-bsvd42 April 19, 2020 01:37 Inactive
Copy link
Member

@shcheklein shcheklein left a comment

Choose a reason for hiding this comment

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

Shared feedback in private

@jorgeorpinel
Copy link
Contributor

Tested on https://dvc-landing-right-panel-bsvd42.herokuapp.com/doc/command-reference/checkout and this works, thanks! I'd approve it but it sounds like Ivan has some other feedback.

@nisarhassan12
Copy link
Contributor Author

Shared feedback in private

Thanks! @shcheklein I have updated the Pr accordingly. Please have a look whenever you'll have time.

@shcheklein shcheklein temporarily deployed to dvc-landing-right-panel-lul3q9 April 25, 2020 04:06 Inactive
@shcheklein
Copy link
Member

@nisarhassan12 I still do have some strange behavior for the right panel after going back - try to open https://dvc-landing-right-panel-lul3q9.herokuapp.com/doc/command-reference/diff#example-checking-workspace-changes , open a few collapsible sections there, click to some link, go back and use the right content panel.

@shcheklein
Copy link
Member

Also, what will we be getting in IE 11?

@nisarhassan12
Copy link
Contributor Author

Also, what will we be getting in IE 11?

@shcheklein According to MDN window.localStorage is availabe in IE if the version is 8 or above.
image

I'm sorry I can't test in an actual IE 11 because I use Arch as my OS.

but let say if a browser is very old and does not support localStorage then state of the collapsed panel won't be persisted although the back button would take you to the exact location.

A bit un-related: the site currently uses CSS custom properties which are not supported at all in all versions of IE and old versions Edge( source: https://caniuse.com/#feat=css-variables ) I would recommend not using them if you want to support IE and other older browsers.

image

@shcheklein
Copy link
Member

@nisarhassan12 thanks! IE is no a top-top priority - the only thing we want to avoid is a complete crash on it and Sentry complaining.

Re this PR - please take a look here #1166 (comment) .

@nisarhassan12
Copy link
Contributor Author

nisarhassan12 commented Apr 26, 2020

@nisarhassan12 I still do have some strange behavior for the right panel after going back - try to open https://dvc-landing-right-panel-lul3q9.herokuapp.com/doc/command-reference/diff#example-checking-workspace-changes , open a few collapsible sections there, click to some link, go back and use the right content panel.

Thanks! @shcheklein I'll try to fix this.

@shcheklein shcheklein temporarily deployed to dvc-landing-right-panel-lul3q9 April 28, 2020 18:45 Inactive
@shcheklein shcheklein temporarily deployed to dvc-landing-right-panel-lul3q9 April 28, 2020 19:02 Inactive

exports.wrapPageElement = PageWrapper

exports.onPreRouteUpdate = ({ location, prevLocation }) => {
Copy link
Member

Choose a reason for hiding this comment

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

can we make collapsible itself saving this on the expnasion? don't like that we do this global search on every navigate

let details = []
try {
details = JSON.parse(localStorage.getItem('details') || '[]')
} catch {}
Copy link
Member

Choose a reason for hiding this comment

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

silent catch is bad? what kind of errors do we expect here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

an error can occur when localStorage is not supported or it fails to parse what is coming back from localStorage which can happen if someone goes into localStorage and set the value for the key to something like {, ']' and so on i.e when there is invalid JSON.

Since we are returning the empty array no matter what the app won't break.

I think adding a console.log would be helpful.

const text = filteredChildren[0].props.children[0]
let details = getDetails()
const detailTitle = filteredChildren[0].props.children[0]
const detailText = getText(filteredChildren.slice(1))
Copy link
Member

Choose a reason for hiding this comment

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

we need a better way to determine the specific collapsible. collecting the whole text feels too much, expensive.

@nisarhassan12
Copy link
Contributor Author

I'm closing this PR as it does not fixes the issue and would add complexities to the codebase.

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

Successfully merging this pull request may close these issues.

navigation: browser history navigation is broken
3 participants