storybookjs / storybook Public
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
Firefox zoom implementation breaks position: fixed elements in Docs #16774
Comments
|
@idesigncode Thanks for a great bug report! I have done some work on the zoom feature in the past and I might be able to help. Going through your examples I can't really see an obvious solution to the problem but I'm going to fire up my development environment over the weekend and see what I can figure out. @idesigncode Are you interested in figuring out a solution for this issue too? |
|
Hey @Tomastomaslol, all good, yeah the solution isn't obvious to me either... For my specific use case I would be happy to disable the zoom feature on the affected stories as long as that also removed the Happy to help test and be involved in the discussion but I'm not familiar with the source code. |
|
Is the story rendered graphically in code? |
|
I had a look at this and the behaviour is inconsistent across the 2 browsers. @idesigncode, Could you please explain your use case? To me, the behaviour in firefox looks more correct than in chrome. I would expect the element you are previewing to be positioned relative to the "story wrapper". In the attached screenshot I added a green box around what I consider to be the "story wrapper." |
|
@Tomastomaslol, sure thing: My use case is documenting a tooltip component that is always visible within the window (if opened). This is achieved by using The calculated values are based off getBoundingClientRect which essentially is expecting the first In Firefox, the first ancestor with the It may be worth noting that all other browsers I've tested this in behave like Chrome so Firefox does appear to be the odd-one-out in regards to this issue. |
|
How can I contribute to this project? I have moderate knowledge of HTML CSS and Javascript! |
|
can you guys provide me a simple website code ? |
|
Hey @idesigncode could you please suggest me , how do I start contributing to this project .I am new to the world of open source contribution. Please help me |
|
|
Is this still an active problem? |
|
@Stroudnat Yes, I'm not aware of any recent changes to resolve this. |
|
Thanks @idesigncode just got around to cloning everything and looking at issue repos so Ill check back if I see anything! |
|
@idesigncode in our Design System, to fix this issue with Firefox we used React's |
|
@konsalex sounds interesting... is that in Storybook or the component itself? Can you provide any code examples? |
|
@idesigncode I implemented this in the component it's self. Cannot share code example at the moment, but in a higher level Before it was a which was breaking with getBoundingClientRect, and the approach of wrapping it with a portal like this, const Portal = ({ children, container }: PortalProps) => {
return ReactDOM.createPortal(children, container);
};solve the issue |
|
Test |
|
I do not expect there is an ideal fix here as the inconsistency lies in the browsers' implementation of the But if I may propose an alternative: only apply the I believe the zoom feature is the only reason to use the |



Describe the bug
In Firefox, the zoom feature uses
transformstyles (see #12845) - unfortunately this breaks positioning on elements that requireposition: fixedwhen in the "Docs" view.Normally a
position: fixedelement's position would correspond to the viewport but in Firefox it corresponds to the element with thetransformstyle.The issue is present regardless of actually using the zoom feature. I have tried to disable the zoom feature (related feature request: #16771) in the hopes that it might also remove the styling used for zoom, however, the styling remains.
To Reproduce
I created a simplified reproduction of the issue here: https://github.com/idesigncode/bug-storybook-firefox-position-fixed
To view the issue, open the story in Docs view in both Firefox and another browser.
System
System:
OS: macOS 12.0.1
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 14.17.3 - ~/.nvm/versions/node/v14.17.3/bin/node
Yarn: 3.1.0 - /usr/local/bin/yarn
npm: 7.20.0 - ~/.nvm/versions/node/v14.17.3/bin/npm
Browsers:
Chrome: 96.0.4664.55
Edge: 95.0.1020.53
Firefox: 94.0.1
Safari: 15.1
npmPackages:
@storybook/addon-actions: ^6.4.0-rc.7 => 6.4.0-rc.7
@storybook/addon-docs: ^6.4.0-rc.7 => 6.4.0-rc.7
@storybook/addon-essentials: ^6.4.0-rc.7 => 6.4.0-rc.7
@storybook/addon-links: ^6.4.0-rc.7 => 6.4.0-rc.7
@storybook/react: ^6.4.0-rc.7 => 6.4.0-rc.7
Additional context
My actual use case is documenting a tooltip component that uses fixed positioning to stay within the window.
Here's some screenshots of the simplified example:
Chrome✅

Firefox❌

Firefox (with the transform style disabled)✅

The text was updated successfully, but these errors were encountered: