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(hooks): useIsMobile hook should be consistent with CSS media query behavior #6652

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

guscost
Copy link

@guscost guscost commented Feb 14, 2025

Fixes #6123

Using the matches boolean on the media query change event produces better behavior at breakpoint boundaries, because for example window.innerWidth includes the scrollbar width, and comparing this does not always behave exactly like a CSS media query. There may also be the possibility of a race conditions due to a re-layout when checking window.innerWidth itself: https://gist.github.com/paulirish/5d52fb081b3570c81e3a

Copy link

vercel bot commented Feb 14, 2025

@guscost is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

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.

[bug]: Sidebar useIsMobile doesn't change when slowly
1 participant