Skip to content

Commit 5082157

Browse files
committed
8367602: Regression: TabPane with wrapped label calculates wrong initial size
Backport-of: 7e692bd
1 parent 8c84c38 commit 5082157

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

modules/javafx.controls/src/main/java/javafx/scene/control/skin/TabPaneSkin.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import javafx.event.EventHandler;
5858
import javafx.geometry.Bounds;
5959
import javafx.geometry.HPos;
60+
import javafx.geometry.Orientation;
6061
import javafx.geometry.Point2D;
6162
import javafx.geometry.Pos;
6263
import javafx.geometry.Side;
@@ -292,7 +293,11 @@ public TabPaneSkin(TabPane control) {
292293
// The TabPane can only be as wide as it widest content width.
293294
double maxw = 0.0;
294295
for (TabContentRegion contentRegion: tabContentRegions) {
295-
maxw = Math.max(maxw, snapSizeX(contentRegion.prefWidth(-1)));
296+
double dependentHeight = contentRegion.getContentBias() == Orientation.VERTICAL
297+
? Math.max(0, contentRegion.prefHeight(-1) - topInset - bottomInset)
298+
: -1;
299+
300+
maxw = Math.max(maxw, snapSizeX(contentRegion.prefWidth(dependentHeight)));
296301
}
297302

298303
final boolean isHorizontal = isHorizontal();
@@ -310,7 +315,11 @@ public TabPaneSkin(TabPane control) {
310315
// The TabPane can only be as high as it highest content height.
311316
double maxh = 0.0;
312317
for (TabContentRegion contentRegion: tabContentRegions) {
313-
maxh = Math.max(maxh, snapSizeY(contentRegion.prefHeight(-1)));
318+
double dependentWidth = contentRegion.getContentBias() == Orientation.HORIZONTAL
319+
? Math.max(0, contentRegion.prefWidth(-1) - leftInset - rightInset)
320+
: -1;
321+
322+
maxh = Math.max(maxh, snapSizeY(contentRegion.prefHeight(dependentWidth)));
314323
}
315324

316325
final boolean isHorizontal = isHorizontal();

0 commit comments

Comments
 (0)