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

Could it be better to adjust width of some html element ? #1054

Open
4 tasks done
gyhyfj opened this issue Jul 24, 2022 · 8 comments · May be fixed by #1844
Open
4 tasks done

Could it be better to adjust width of some html element ? #1054

gyhyfj opened this issue Jul 24, 2022 · 8 comments · May be fixed by #1844
Labels
enhancement New feature or request stale theme Related to the theme

Comments

@gyhyfj
Copy link
Contributor

gyhyfj commented Jul 24, 2022

Is your feature request related to a problem? Please describe.

There's a little different of layout among pages have y-scrollbar or not in wide screen device like desktop.
For example, if I switch pages like https://vitepress.vuejs.org/guide/theme-search.html and pages like https://vitepress.vuejs.org/guide/markdown.html , there will be a little quake , cause some components' width changed.

Describe the solution you'd like

overwrite css rule... but many place to adjust, not only #VPContent

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd brc-dd added enhancement New feature or request theme Related to the theme labels Jul 24, 2022
@brc-dd
Copy link
Member

brc-dd commented Jul 24, 2022

There used to be some stuff like overflow-y: overlay that would prevent that layout shift in webkit browsers (edit: -ms-overflow-style: -ms-autohiding-scrollbar for IE/old edge) (if you want you can still add that on body, its deprecated but it still works on latest chrome). On Firefox, they now default to overlay scrollbars so everything already looks fine there.

@CHOYSEN
Copy link
Contributor

CHOYSEN commented Jan 17, 2023

Maybe scrollbar-gutter can solve this problem.

zqianem added a commit to zqianem/vitepress that referenced this issue Jan 26, 2023
@zqianem zqianem linked a pull request Jan 26, 2023 that will close this issue
@kiaking
Copy link
Member

kiaking commented Feb 27, 2023

I'm not 100% sure if we should fix this. Personally, I like it when there's no layout shift happening. However, this behaviour is how Windows works... right? I mean it happens by default to any sites, not VitePress exclusive issue.

I'm a Mac user so I don't know whole lot on how Windows users feel about this issue in general, but... wouldn't this be normal for them? In that case, fixing this issue is like hacking Windows behaviour and I don't know if that's a good idea 🤔

Anyone has insight on this? Like is there any best practice to handle scrollbar thing, or famous websites doing the same thing and people loving it and such.

@gyhyfj
Copy link
Contributor Author

gyhyfj commented Feb 27, 2023

I add overflow: overlay to html and it works well now. As webkit browsers' behaviour, people don't need to care about it only if switch pages with/without scrollbar frequently.
Another solution is set display: none to scrollbar of layout, and then simulate it by div, but the problem is performance and complexity

@kiaking
Copy link
Member

kiaking commented Feb 28, 2023

Yeah I mean I can come up with several different way to solve the layout shift too, but the question is should we fix it? (is it even a fix?) 🤔 Because isn't this how Windows work?

@zqianem
Copy link
Contributor

zqianem commented Mar 16, 2023

I think this is worth fixing for the case of opening the search modal. Currently, opening the modal (Ctrl+K) on Vitepress causes a layout shift on Windows while similar functionality on other sites (e.g. Ctrl+Alt+K on GitHub, Ctrl+K on Netlify) does not.

Modal implementations in some popular component libraries also do not cause a layout shift on Windows:

Edit: just rebased my PR for this and can confirm the fix still works

zqianem added a commit to zqianem/vitepress that referenced this issue Mar 16, 2023
@kiaking
Copy link
Member

kiaking commented Mar 27, 2023

Oh, yes, Modal thing should be fixed. And yeah that makes sense. Let's fix this issue then 💪

zqianem added a commit to zqianem/vitepress that referenced this issue Jun 10, 2023
@zqianem
Copy link
Contributor

zqianem commented Jun 10, 2023

Rebased #1844 and can confirm that the fix implemented there still works.

I tried the alternatives mentioned earlier in this thread but there are some issues with each:

  • scrollbar-gutter shows the gutter above the modal scrim
  • overflow: overlay shows the scrollbar above the modal scrim and doesn't prevent the underlying content from scrolling

@brc-dd and @kiaking, is there anything I can change to get this PR merged? There were some concerns mentioned on the original PR that I could try to address if more details are provided.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale theme Related to the theme
Projects
None yet
5 participants