bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

modal display issue in chrome

Open umb-zz opened this issue 14 years ago • 15 comments

Hello. There seems to be a display bug with modal in chrome, when you launch any bootstrap modal in chrome, there is a 10px (roughly? inspecting element is no help) margin down the right side of the model that seems to randomly display. when you click either the close or save modal buttons in the footer it corrects its position on mouse down.

this happens even on the demo modal popup located at http://twitter.github.com/bootstrap/javascript.html#modals issue does not seem to be reproducible in firefox, however 1-5 hard refreshes in chrome seems to replicate the problem, at least on my end.

screenshot of margin. http://i.imgur.com/DogAK.png

umb-zz avatar Jun 29 '12 17:06 umb-zz

which version of chrome and which os is this issue occuring on?

ghost avatar Jul 01 '12 18:07 ghost

win 7 x64

21.01180.15 dev-m

I didn't realize i was using a development build still. I will check it on stable and see if i can still replicate the issue.

i can not seem to replicate this issue in current versions of chrome stable or chrome beta, i guess this was a dev-m specific issue.

closing this ticket.

umb-zz avatar Jul 02 '12 20:07 umb-zz

I know this issue was closed, but I ran in to this today while working on a project. It happens exactly as described in the original message...

A 10(ish) px margin or padding down the right side of the modal, clicking buttons in the modal footer or header causes the modal to jump to its normal positioning. Inspecting the element also causes it to jump to the normal position.

I couldn't reproduce it in firefox or IE, but it happens consistently in Chrome(21.0.1180.60 m). I am able to reproduce it in the demo as well. Just by clicking open/close over and over.

I was glad to find that someone else had run into this. I hadn't even thought to try it on the demo, now that I know it's not something I have done wrong I can just move on to something else and quit wasting time on it.

cwitt1 avatar Aug 06 '12 18:08 cwitt1

Yep, I'm seeing it too, playing with the demo, it is happening for me maybe 1 in 10 times.

Win7 x64 Chrome 21.0.1180.60 m

Maybe this is a Chrome bug and not Bootstrap?

bproctor avatar Aug 06 '12 19:08 bproctor

i verified this to be a chrome dev-m only bug at the time of the initial ticket, i'm guessing that its made it to beta or stable?

umb-zz avatar Aug 06 '12 20:08 umb-zz

Yeah I think its a chrome bug due to the intermittent nature of it. It's just a minor inconvenience, and it's fairly rare, so I'm just going to keep a mental note in case any of my users complain about it. I just wanted to bump this in case anyone else wasted a couple hours trying to fix it. =)

I wonder if someone should notify the guys working on the chromium project? I'm not even sure how to explain it without leaving an opening for them to point the finger back at bootstrap.

cwitt1 avatar Aug 06 '12 20:08 cwitt1

Confirmed in Chrome 21.0.1180.60 m on Windows 8 x64 Release Preview with official Bootstrap modal demo. Occurs roughly 1 in 5 times without having to refresh (just close and reopen modal continuously until you see the margin on the right). The #myModal container is the same size regardless of the presence of the issue - the header, body and footer are shrinking down from 560px to 543px in width without Chrome registering any margins or padding (thus no reason for Chrome to be rendering them too narrow).

Appears to only occur when the modal contains a scrollable region, as I can't reproduce it on modals without. The gap also appears to be about the same width of Chrome's scrollbar (17px gap vs. 16px Chrome scrollbar) - not sure if it's related. Anything that changes in the DOM forces Chrome to re-render the modal correctly (clicking a button in the modal, opening Chrome's console, clicking an element in the element inspector, etc.)

Possible workaround: use JavaScript/jQuery to force an invisible change to the DOM right after .modal() is triggered.

UPDATE: The workaround works. Sure, it's a bit hacky, but it's the best I could come up with for now. Fiddle: http://jsfiddle.net/xXS97/4/

clowerweb avatar Aug 08 '12 23:08 clowerweb

Confirmed in Chrome 21.0.1180.60 m on Windows 8 x64 Release Preview as well. I also tested @clowerweb 's workaround and it does indeed work, though as noted, a bit hacky as you can sometimes visibly see the 'snap' as the margin disappears.

Also happens on 21.0.1180.75 m

finaiized avatar Aug 10 '12 04:08 finaiized

Ubuntu 12.04 x64, Chrome 21.0.1180.75

Seems like a Chrome bug to me, the margin has exactly the same width the scrollbar does. Changing the viewport's height (opening the web inspector docked and resizing it) triggers the bug, toggling a second scrollbar on and off on #myModal—sometimes leaving such margin when this scrollbar disappears, inclusive on @clowerweb 's workaround.

I tried the same strategy on Firefox (14.0.1) using firebug, but I could not reproduce the bug.

raphaelnova avatar Aug 10 '12 13:08 raphaelnova

@rboanova: I was able to reproduce the same issue using Chrome 21.0.1180.75 with OpenSUSE 12.1. Using the official demo the bug triggers, when there isn't enough space to display the entire modal. Using the workaround the scrollbars appear randomly.

scento avatar Aug 10 '12 15:08 scento

Ok, I finally got the chance to revisit this issue and look into it further. In the Fiddle I posted above, I noticed that, if you open up the Chrome element inspector, a scrollbar appears on the right side of the main div.modal. This became obvious because the Fiddle result is in the lower portion of the screen.

This is likely the cause of the gap, even though the scrollbar doesn't physically appear (or at least stay) unless the modal is moved via a change in the size of the viewport. Thus, this issue is both a Chrome bug and a possible oversight in the Twitter Bootstrap CSS.

Updated workaround (no JS):

div.modal { overflow: hidden; }​

This forces browsers not to render a scrollbar on the main modal container.

Fiddle: http://jsfiddle.net/xXS97/5/

TL;DR:

Cause of bug: Chrome is placing a scrollbar on the main div, even though it may not be shown. Even after the browser removes the scrollbar, the margin that it placed there for the scrollbar is not removed.

clowerweb avatar Aug 11 '12 04:08 clowerweb

Experiencing same issue the opening poster described in chrome 21.0.1180.82 with os x 10.6.8. Clowerweb's workaround seems to fix it.

onedrop avatar Aug 23 '12 02:08 onedrop

@clowerweb thanks very much! this fixed the issue!

abreu-dev avatar Sep 07 '12 20:09 abreu-dev

Best workaround without feature lost, no JS :

.modal-body {
    position: static;
    padding-bottom: 18px;
}

fdaugan avatar Jul 16 '13 08:07 fdaugan

Good work @fabdouglas ;-)

IReivax avatar Jul 16 '13 09:07 IReivax