Live data from Hacker News

A Better Twitter Bootstrap Modal

github.com

41–50 of 73 posts

Re: A Better Twitter Bootstrap Modal

#41
The first that I personally have seen so far that doesn't screw up when zooming in on a mobile device (actually resizes and re-positions itself), so great job! I'm sure there are others, but this one is now the best in my opinion solely based on that regard.

Re: A Better Twitter Bootstrap Modal

#42
post #39

Earlier quoted context omitted.

Is it really worth installing an entirely new library just to achieve something a simple line of CSS could do? .modal-background { background:white; } For me, Twitter Bootstrap's components have been the right tradeoff between flexibility and functionality. It doesn't have too many bells and whistles which makes it way easier to integrate into my own code. Maybe I just haven't run in to the use cases for Bootstrap's…

This is a drop-in replacement so that once you hit those use cases, you won't have the pain others have already felt before you. =)

I don't think it's safe to assume that a niche feature upgrade to a JS/CSS framework is inherently bug-free across browsers.

Re: A Better Twitter Bootstrap Modal

#44
post #42

Earlier quoted context omitted.

This is a drop-in replacement so that once you hit those use cases, you won't have the pain others have already felt before you. =)

I don't think it's safe to assume that a niche feature upgrade to a JS/CSS framework is inherently bug-free across browsers.

That isn't the question. The question is if jschr's modal implementation is more (or less) bug free than bootstrap's. Based on my analysis and many others, it is more bug free. Feel free to read through the issues. https://github.com/twitter/bootstrap/issues/search?q=modal

Re: A Better Twitter Bootstrap Modal

#46
It suffers from the same bug as the stock bootstrap modal; focus is not contained in the popup window. Press tab a few times and soon your keyboard focus is on elements on the page behind the modal.

Re: A Better Twitter Bootstrap Modal

#49
post #48
post #46

It suffers from the same bug as the stock bootstrap modal; focus is not contained in the popup window. Press tab a few times and soon your keyboard focus is on elements on the page behind the modal.

Is there even a way to avoid that?

Not without heavy js code

Re: A Better Twitter Bootstrap Modal

#50
post #49
post #48

Earlier quoted context omitted.

Is there even a way to avoid that?

Not without heavy js code

Well, I actually submitted a pull-request almost a year ago but it was rejected for "complexity"...

I didn't understand that decision back then and I don't understand it today. The patch weighs in at about 100 lines which doesn't seem heavy to me. Especially when you consider that without the patch the bootstrap-"modal" is not a modal...

Anyway, here's the fixed bootstrap-modal.js for the version that was current back then:

https://gist.github.com/0d04646ab6cf4df50610

Line 23-82 is the important bit, that snippet is lifted nearly 1:1 from jquery.ui.dialog which fixed this issue ages ago. Beyond that there's only a couple lines of glue code.

Feel free to port this forward to the current version (or better-modal). Personally I've stopped using the javascript parts of bootstrap because I don't want to maintain forks for basic bugs like that.

Post reply on HN