Margins are not collapsed because of `slate-data-spacer`
See original GitHub issueDo you want to request a feature or report a bug?
- Bug
Example to reproduce : https://jsfiddle.net/BanB4n/gszke21n/14/ Informations: MacOS, Google Chrome, Slate 0.33
What’s the current behavior?
The data-slate-spacer
div prevents the collapsing of margin.
What’s the expected behavior?
At GitBook, we fixed this by adding position: absolute
to the data-slate-spacer
element. But we are not confident about this solution, since we are not sure to understand the purpose of this spacer
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Mastering margin collapsing - CSS: Cascading Style Sheets
Margin collapsing occurs in three basic cases: Adjacent siblings. The margins of adjacent siblings are collapsed (except when the latter sibling ...
Read more >Why are margins not collapsing? - css - Stack Overflow
Flex items' margins won't collapse. When flex items wrap, they create their own row, and the individual margins on the flex items won't ......
Read more >What is Margin Collapse in CSS? And How to Avoid It
Margin collapse can cause unexpected behaviors in your layout. You'll likely see applied spacing that doesn't seem to match up with what you ......
Read more >The Rules of Margin Collapse - Josh W Comeau
You can think of padding/border as a sort of wall; if it sits between two margins, they can't collapse, because there's a wall...
Read more >What You Should Know About Collapsing Margins | CSS-Tricks
The bartender asks if he should be cut off and the spacing replies, “No, I'm just a collapsed margin.” Sorry, dumb joke.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
In our project, we render Markdown documents using Slate. The images in a document are rendered as inline nodes. With this change (adding
position: 'absolute'
), when an inline image is clicked, the view will jump to an incorrect scroll position.In
scrollToSelection()
https://github.com/ianstormtaylor/slate/blob/1923888af1b07b6c21ea20b0a9f054a5cbb27654/packages/slate-react/src/utils/scroll-to-selection.js#L74returns incorrect cursorRect.
Hope a better solution can be found.
I have the editor in a scrolling div and experienced the same problem as @freeplant, except that it didn’t seem to matter whether the image was inline or block.
In my case the solution was to set “position: relative” to the editor area (or an immediate wrapper). Without it absolute position was off and the view jumped when focusing on images.