Skip to content

Button size is not correctly set if it is created inside an element hidden with display: none #167

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

Open
silentnights opened this issue Jun 4, 2017 · 5 comments

Comments

@silentnights
Copy link

Hi,
The button sizes are not correctly set if it was created in a display: none element. Apparently the size calculation below is not correctly calculating the size if the element has display: none css property:
var width = this.options.width || Math.max($toggleOn.width(), $toggleOff.width())+($toggleHandle.outerWidth()/2)

From the above all width() functions return zero which is not the correct size when the display is set back to block.

This makes the sizes not correct whenever you create the elements inside bootstrap tabs as an example.

I have set an explicit width, which fixes the issue, but I hope there would be a global fix for this.

@CharlieEtienne
Copy link

Same here, for example it doesn't work when placed in a modal.

@Deekor
Copy link

Deekor commented Mar 2, 2019

Yup not working in a bootstrap tab that is hidden at first.

@cahpalencia
Copy link

Same problem here when used in hidden tabs.

@Pointotech
Copy link

Same problem.

@huyz
Copy link

huyz commented Jan 27, 2021

This looks like a duplicate of #106 , which lists an open PR and some forks with solutions.

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

No branches or pull requests

6 participants