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

Addon Centered causes component to disappear when zooming #7167

Closed
CodeByAlex opened this issue Jun 21, 2019 · 20 comments · Fixed by #7400
Closed

Addon Centered causes component to disappear when zooming #7167

CodeByAlex opened this issue Jun 21, 2019 · 20 comments · Fixed by #7400

Comments

@CodeByAlex
Copy link
Member

CodeByAlex commented Jun 21, 2019

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Open a component that uses addon centered
  2. use the + or - magnifying glass in storybook
  3. component will disappear

Expected behavior
Component shouldnt disappear.

Screenshots
centered-zoom-bug

System:

  • Browser: [chrome]
  • Framework: [react, angular, and more?] example above is from the official storybook
  • Version: [at least as of addon centered: 5.1.1 will have to check on 5.0 versions]
@ndom91
Copy link
Contributor

ndom91 commented Jun 25, 2019

Can confirm I have the same issue.

@CodeByAlex
Copy link
Member Author

CodeByAlex commented Jun 26, 2019

@ndom91 is this something that you would like to take a look into? I don't think it would be a terribly difficult task and we are always looking for people to contribute 😄

@ndom91
Copy link
Contributor

ndom91 commented Jun 26, 2019

@CodeByAlex yeah ill take a look at it this evening when I have some free time :)

I was hoping someone else had maybe already found a solution haha

@ndom91
Copy link
Contributor

ndom91 commented Jun 28, 2019

So unfortunately I dont have a solution yet, but I did find some things - maybe it will ring a bell for someone else..

The element disappears immediately once any css transform is applied, be it scale, transformX, translateY, translateZ, etc.

In this case the zoom button adds a translate: scale(1.25), for example. If you take this property off in the dev tools the element reappears. I did some googling and none of the common suggestions fixed the issue.

There is kind of a work-around which I discovered which we could implement, and that is using zoom(1.25) instead.

According to MDN zoom is a 'non-standard' property though, but has pretty good browser compatibility:

image

https://developer.mozilla.org/en-US/docs/Web/CSS/zoom

image

https://caniuse.com/#feat=css-zoom

@8beeeaaat
Copy link
Contributor

8beeeaaat commented Jul 12, 2019

@shilman

I found the solution.
The body element should styled

lib/core/src/server/templates/base-preview-head.html

html, body{
  width: 100%;
  height: 100%;
}

Jul-12-2019 21-54-07

@ndom91
Copy link
Contributor

ndom91 commented Jul 12, 2019

Looks good on my end too! Have you made a pull request?

@8beeeaaat
Copy link
Contributor

8beeeaaat commented Jul 12, 2019

@ndom91
Sorry, I couldn't make PR...
I can't push commit with permission error.
I'm not Storybook's member.

@ndom91
Copy link
Contributor

ndom91 commented Jul 12, 2019

If you clone it first, make your change in your cloned version, and then you should be able to make a PR from there.

@8beeeaaat
Copy link
Contributor

Wow!! I'll try it!!

@ndom91
Copy link
Contributor

ndom91 commented Jul 12, 2019

Yes, this is the standard way to do it if you dont have the rights to the repo.

See, for example, this pull request: #7397

It is from @ctavan's clone, back into storybookjs:next branch

@8beeeaaat
Copy link
Contributor

8beeeaaat commented Jul 12, 2019

@ndom91
I made PR #7400 !
Thank you very much for guiding me! !

CodeByAlex added a commit that referenced this issue Jul 22, 2019
Fix #7167 addon-centered causes component to disappear when zooming
@shilman
Copy link
Member

shilman commented Jul 22, 2019

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-beta.6 containing PR #7400 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

@8beeeaaat
Copy link
Contributor

@shilman
Thanks!!🙌

@shilman
Copy link
Member

shilman commented Jul 31, 2019

Son of a gun!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.1.10 containing PR #7400 that references this issue. Upgrade today to try it out!

@shilman
Copy link
Member

shilman commented Aug 2, 2019

Yay!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-beta.21 containing PR #7640 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

@shilman
Copy link
Member

shilman commented Aug 13, 2019

@CodeByAlex @ndom91 @8beeeaaat @quentind @Hypnosphi @ndelangen @tmeasday

I'm reverting #7640 and #7400. We should not be modifying the preview styles since it can conflict with the user's style and break visual tests (among other things).

We'll have to come up with a different solution to this problem. @Hypnosphi suggested body {transformOrigin: center center;} as an option. Whatever we do it's important that it's only applied to centered stories.

@CodeByAlex
Copy link
Member Author

CodeByAlex commented Aug 13, 2019

@shilman thats a really good point. I will say that addon centered applies styles to the component to place it in the center to begin with as seen here: https://github.com/storybookjs/storybook/blob/next/addons/centered/src/styles.ts

If we want to make sure that styles aren’t interfering(which makes sense), we may want to consider how the addon works from the ground up.

shilman added a commit that referenced this issue Aug 13, 2019
…th-addon-centered

Core: Revert "Fix #7167 addon-centered causes component to disappear when zooming"
@shilman shilman reopened this Aug 13, 2019
@shilman
Copy link
Member

shilman commented Aug 13, 2019

Yay!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-beta.29 containing PR #7749 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

@shilman shilman closed this as completed Aug 13, 2019
@shilman shilman reopened this Aug 13, 2019
shilman added a commit that referenced this issue Aug 13, 2019
…th-addon-centered

Core: Revert "Fix #7167 addon-centered causes component to disappear when zooming"
@stale
Copy link

stale bot commented Sep 3, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@shilman
Copy link
Member

shilman commented Oct 17, 2019

Boo-yah!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.21 containing PR #8442 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

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