Vertical scrolling broken in Safari & Firefox when using Flexbox. #4895
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
If a CodeMirror (5.28) instance is contained in an element with
display:flex, vertical scrolling breaks on Safari & Firefox. The symptom is different for each browser:Firefox 54: Scrolling is disabled, and the CM instance sizes to fit its content.
Safari 10.1.1: The outer
.CodeMirrorelement & scrollbar resizes correctly, but the inner.CodeMirror_scrollelement displays at a fixed pixel size with a horizontal scroll bar.Chrome 59: appears to work fine.
Example of the issue:
https://jsfiddle.net/m37txcka/1/
Setting
.CodeMirror_scrolltoposition:absoluteseems to resolve this issue, but it causes the vertical scrollbar to always show, and I'm worried that it's going to introduce other problems.Example of the "fix":
https://jsfiddle.net/m37txcka
Happy to modify the enclosing HTML to work around this if there's a known solution, but I need the Flexbox layout functionality.
Thanks!
I think this is a duplicate of #4142 , though it's interesting to see that it also occurs for vertical flex layout. A solution is to introduce an additional wrapping
<div>around the editor, so that it's direct parent isn'tdisplay: flex. Firefox and Safari appear to have a bug where they'll ignore the staticheightof the.CodeMirrordiv in this situation. (At least, the way I understand the spec, that's not the correct behavior.)mentioned in issue #4142
After some fussing around, I was able to find a solution that appears to size correctly and maintains autohide on the scrollbars. As Marijn suggested, this involved wrapping the CodeMirror element in a parent div. The parent div (which is sized via its flexbox parent) needs to have
position:relativeset, and the CodeMirror element needs to haveposition:absoluteset. You can then set CodeMirror to 100% / 100% and it will fill the available space.Here's a working example for anyone encountering the same issue:
https://jsfiddle.net/m37txcka/4/
Thanks for the help Marijn!