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: proper collapsing of long element #5694

Merged
merged 5 commits into from
Oct 15, 2021
Merged

fix: proper collapsing of long element #5694

merged 5 commits into from
Oct 15, 2021

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Oct 12, 2021

Motivation

There seems to be a regression after #5146
At least probably on sidebar items with large children the collapsing transition does not complete correctly.

You can see this now on the Redux site if you click on "Using Redux" in sidebar. https://redux.js.org/introduction/getting-started

Actual Expected
image image

This is due to the fact that initially scrollable element height via scrollHeight is not calculated correctly with overflow:hidden. I don't really understand why this happens on some elements. For example, on the Docusaurus site this bug doesn't reproduce (https://docusaurus.io/tests/docs)

So in order to get a consistent behavior, we don't need to check collapsible element height after completing transition. However, considering that in #5146 we introduced extra requestAnimationFrame call, this will still mitigate issue with multiple clicks.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Try to apply this patch to Redux site locally.

Related PRs

(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)

@lex111 lex111 added the pr: bug fix This PR fixes a bug in a past release. label Oct 12, 2021
@lex111 lex111 requested a review from slorber as a code owner October 12, 2021 07:57
@netlify
Copy link

netlify bot commented Oct 12, 2021

✔️ [V2]

🔨 Explore the source changes: 2a6f968

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/6169792ef021490008760d3f

😎 Browse the preview: https://deploy-preview-5694--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Oct 12, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟢 Performance 91
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5694--docusaurus-2.netlify.app/

@github-actions
Copy link

github-actions bot commented Oct 12, 2021

Size Change: +4.46 kB (+1%)

Total Size: 841 kB

Filename Size Change
website/build/assets/css/styles.********.css 93.8 kB -126 B (0%)
website/build/assets/js/main.********.js 425 kB +3.58 kB (+1%)
website/build/blog/2017/12/14/introducing-docusaurus/index.html 67.3 kB +320 B (0%)
website/build/docs/index.html 45.3 kB +310 B (+1%)
website/build/docs/installation/index.html 53.8 kB +352 B (+1%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 38.3 kB 0 B
website/build/blog/index.html 38.1 kB +6 B (0%)
website/build/index.html 30.8 kB +6 B (0%)
website/build/tests/docs/index.html 26.2 kB +6 B (0%)
website/build/tests/docs/standalone/index.html 22.9 kB +6 B (0%)

compressed-size-action

@slorber
Copy link
Collaborator

slorber commented Oct 12, 2021

Hey

I'm not sure to understand how to reproduce or test this fixed the Redux doc issue.

image

Redux is not using beta.6/canary, can this be reproduced with latest?

What I see is that the scrollbar is covered by some white rectangle, so this doesn't seem related to the collapsible component to me.

This seems related to the announcement bar CSS var, disabling this CSS fixed the problem:

image

@lex111
Copy link
Contributor Author

lex111 commented Oct 12, 2021

I can reproduce it on the latest version, here on another site

https://docs.tuist.io/tutorial/get-started/

image

menuWith... is not related to this bug, but this class should not be here, I'll see what's wrong.

@Josh-Cena
Copy link
Collaborator

Related to #5254? Would that be properly fixed... or is it only fixable with scrollbar-gutter?

@slorber
Copy link
Collaborator

slorber commented Oct 12, 2021

Oh yes those are 2 distinct issues.

Yes @Josh-Cena is right this is related to the sidebar item width decreasing when the scrollbar appears, when items wrap on 2 lines. The collapsible height computation is probably done before the scrollbar appears.

If we used a label that wraps/unwraps on Docusaurus docs test instance, we could see in the preview if current code fixes the issue.

Example label on Tuist: Commands > Manage external dependencies

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 13, 2021
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

It seems to reintroduce issues with the mobile collapsible TOC that the referenced PR did solve (it works better in prod than in the deploy preview when clicking fast in it)

Also I'm not sure it solves the Redux issue without testing it locally: can you add sidebar config in Docs test instance so that we can see it fixes it?

Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

It seems to fix the reported problem, but still don't think it's ready, as it reintroduces an annoying behavior fixed in #5146

I can see the deploy preview behavior is worst than the production on all collapsible

Comment on lines 25 to 34
items: [
...generateHugeSidebarItems(4),
...[
{
type: 'link',
href: '/',
label: 'Test Test test test test test test',
},
],
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why ... instead of just adding the item at the beginning?

Also I'd suggest adding that example at the very beginning. Adding it at the end makes it not clear that it actually wraps, because we don't see it moving from 1 line to 2 lines (at least on my screen). I had to remove the scrollbar with devtools to be sure it does.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, it didn't seem to matter to me, but I moved it to top of list.

reintroduces an annoying behavior

Yes, but it still not as annoying as the current issue. I still can't find better solution.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The wrapping affects only a few sites (it's worst but unless bad luck the last item remains clickable).
The collapsible problem is a smaller problem but it affects all sites in multiple places.

I'd rather wait and find a better solution.

IMHO the solution we want is to ensure the category label does not wrap anymore: #5254 It would solve 2 issues at once

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I disagree, the current issue affects to more sites (not just those two sites) and therefore more serious. The other issue with multiple clicks is a rare case, though. Well then let's initially calculate collapsible element height with possible scrollbar. Any objections?

Copy link
Collaborator

@slorber slorber Oct 15, 2021

Choose a reason for hiding this comment

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

I think we won't agree on this, unfortunately, but I don't like the idea to fix an issue (that none or very few users reported as a major problem) by introducing a regression somewhere else: we must find a way to fix both issues at once.


This new solution is not ideal either.

A scrollbar can temporarily appear as you click:

Oct-15-2021 12-14-04

And if you reduce the size of the category that has a wrapping element, you'll notice some extra height added at the end, and then "fixed" on animation end.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you should consider realistic usage scenarios first. So the scrollbar will not be displayed if the user clicks once -- this is main realistic use case. Why would anyone want to click on a category many many times?

"no user reported" -- that's because users mostly don't care on it, they came to docs site for information, they are not testers. Better ask the owner of Redux site about this issue, he's hardly aware of it because he doesn't test the whole site by clicking on every category, I guess.

@lex111 lex111 merged commit 1361a5a into main Oct 15, 2021
@lex111 lex111 deleted the lex111/collapse-height branch October 15, 2021 13:02
@slorber
Copy link
Collaborator

slorber commented Oct 15, 2021

👍 we agreed on the first proposed solution, temporarily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants