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

[Bug]: Mobile emulator has wrong width on initial render after page reload #27086

Open
nathanpower opened this issue May 10, 2024 · 0 comments
Open

Comments

@nathanpower
Copy link

Describe the bug

When using the viewport width to run some conditional logic on initial render of a component (triggering an animation for example), the initial render will receive the incorrect value

To Reproduce

Simplest way to reproduce is to add

console.log(Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0))

To the body of any component, pick a mobile emulator, and refresh the page.

You should see the full viewport width initially logged, followed by the chosen width of the emulator

Doing the same with browser dev-tools mobile emulation will result in only the latter value being logged

System

Storybook Environment Info:

  System:
    OS: Linux 6.4 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (10) arm64 unknown
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.12.2 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.5.0 - /usr/bin/npm
    pnpm: 8.15.8 - /usr/bin/pnpm <----- active
  npmPackages:
    @storybook/addon-a11y: 8.0.9 => 8.0.9 
    @storybook/addon-actions: 8.0.9 => 8.0.9 
    @storybook/addon-coverage: ^1.0.1 => 1.0.1 
    @storybook/addon-docs: 8.0.9 => 8.0.9 
    @storybook/addon-essentials: 8.0.9 => 8.0.9 
    @storybook/addon-interactions: 8.0.9 => 8.0.9 
    @storybook/addon-links: 8.0.9 => 8.0.9 
    @storybook/addon-mdx-gfm: ^8.0.9 => 8.0.9 
    @storybook/blocks: 8.0.9 => 8.0.9 
    @storybook/cli: 8.0.9 => 8.0.9 
    @storybook/core-server: 8.0.9 => 8.0.9 
    @storybook/jest: 0.2.3 => 0.2.3 
    @storybook/manager-api: 8.0.9 => 8.0.9 
    @storybook/react: 8.0.9 => 8.0.9 
    @storybook/react-vite: 8.0.9 => 8.0.9 
    @storybook/test-runner: 0.17.0 => 0.17.0 
    @storybook/testing-library: 0.2.2 => 0.2.2 
    @storybook/testing-react: ^2.0.1 => 2.0.1 
    @storybook/theming: 8.0.9 => 8.0.9 
    chromatic: ^6.13.1 => 6.13.1 
    eslint-plugin-storybook: ^0.8.0 => 0.8.0 
    storybook: 8.0.9 => 8.0.9 
    storybook-addon-intl: ^4.0.0 => 4.0.0 
    storybook-addon-pseudo-states: 3.0.1 => 3.0.1

Additional context

No response

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

No branches or pull requests

1 participant