Skip to content

Commit 9bba396

Browse files
committed
Treat as block if it's a multi line row
1 parent f0c159a commit 9bba396

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,12 +1237,17 @@ export function applyViewTransitionName(
12371237
// if they have display: block children. We try to work around this bug in the
12381238
// simple case by converting it automatically to display: inline-block.
12391239
// https://bugs.webkit.org/show_bug.cgi?id=290923
1240-
if (countClientRects(instance.getClientRects()) === 1) {
1240+
const rects = instance.getClientRects();
1241+
if (countClientRects(rects) === 1) {
12411242
// If the instance has a single client rect, that means that it can be
1242-
// expressed as a display: inline-block. This will cause layout thrash
1243-
// but we live with it since inline view transitions are unusual.
1243+
// expressed as a display: inline-block or block.
1244+
// This will cause layout thrash but we live with it since inline view transitions
1245+
// are unusual.
12441246
const style = instance.style;
1245-
style.display = 'inline-block';
1247+
// If there's literally only one rect, then it's likely on a single line like an
1248+
// inline-block. If it's multiple rects but all but one of them are empty it's
1249+
// likely because it's a single block that caused a line break.
1250+
style.display = rects.length === 1 ? 'inline-block' : 'block';
12461251
// Margin doesn't apply to inline so should be zero. However, padding top/bottom
12471252
// applies to inline-block positioning which we can offset by setting the margin
12481253
// to the negative padding to get it back into original position.

0 commit comments

Comments
 (0)