From d0b47bc0946e56b85b26cd5bb2515e58972ac18e Mon Sep 17 00:00:00 2001 From: Jonathan Olson Date: Thu, 1 Aug 2024 11:06:57 -0600 Subject: [PATCH] Do not apply max-sizes if size/radius is not specified on rectangular/round buttons, see https://github.com/phetsims/sun/issues/889 --- js/buttons/RectangularButton.ts | 11 +++++++---- js/buttons/RoundButton.ts | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/js/buttons/RectangularButton.ts b/js/buttons/RectangularButton.ts index 2b4d7313..2c9550b3 100644 --- a/js/buttons/RectangularButton.ts +++ b/js/buttons/RectangularButton.ts @@ -495,11 +495,14 @@ class RectangularButtonNodeConstraint extends LayoutConstraint { contentProxy.preferredWidth = preferredContentWidth; contentProxy.preferredHeight = preferredContentHeight; - const contentContainer = this.buttonNode.contentContainer!; - assert && assert( contentContainer ); + // Only apply max sizes if a size is specified in the button, see https://github.com/phetsims/sun/issues/889 + if ( this.options.size ) { + const contentContainer = this.buttonNode.contentContainer!; + assert && assert( contentContainer ); - contentContainer.maxWidth = preferredContentWidth; - contentContainer.maxHeight = preferredContentHeight; + contentContainer.maxWidth = preferredContentWidth; + contentContainer.maxHeight = preferredContentHeight; + } } this.isFirstLayout = false; diff --git a/js/buttons/RoundButton.ts b/js/buttons/RoundButton.ts index e5bdb1c7..5b7ff988 100644 --- a/js/buttons/RoundButton.ts +++ b/js/buttons/RoundButton.ts @@ -430,11 +430,14 @@ class RoundButtonNodeConstraint extends LayoutConstraint { contentProxy.preferredWidth = preferredContentWidth; contentProxy.preferredHeight = preferredContentHeight; - const contentContainer = this.buttonNode.contentContainer!; - assert && assert( contentContainer ); + // Only apply max sizes if a size is specified in the button, see https://github.com/phetsims/sun/issues/889 + if ( this.options.radius !== null ) { + const contentContainer = this.buttonNode.contentContainer!; + assert && assert( contentContainer ); - contentContainer.maxWidth = preferredContentWidth; - contentContainer.maxHeight = preferredContentHeight; + contentContainer.maxWidth = preferredContentWidth; + contentContainer.maxHeight = preferredContentHeight; + } } this.isFirstLayout = false;