Closed marlitas closed 7 months ago
@marlitas and I attempted to run the layout manually, it seems like it could be brought to production with fine-tuning, but it would be better to understand why GridBox isn't working as expected here:
@samreid did some great digging on this, and we found the culprit code:
Subject: [PATCH] Remove maxWidth
---
Index: js/discrete/view/DiscreteControlPanel.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/discrete/view/DiscreteControlPanel.js b/js/discrete/view/DiscreteControlPanel.js
--- a/js/discrete/view/DiscreteControlPanel.js (revision 8a6d4788b7bac1ba4e0a2f673fea0368b346f87f)
+++ b/js/discrete/view/DiscreteControlPanel.js (date 1671044716655)
@@ -179,7 +179,6 @@
} );
const waveformComboBox = new WaveformComboBox( waveformProperty, popupParent, {
- maxWidth: 135,
tandem: options.tandem.createTandem( 'waveformComboBox' )
} );
@@ -280,7 +279,6 @@
} );
const domainComboBox = new DomainComboBox( domainProperty, popupParent, {
- maxWidth: 135,
tandem: options.tandem.createTandem( 'functionOfComboBox' ) // tandem name differs by request
} );
@@ -311,7 +309,6 @@
} );
const equationComboBox = new EquationComboBox( equationFormProperty, domainProperty, popupParent, {
- maxWidth: 135,
tandem: options.tandem.createTandem( 'equationComboBox' )
} );
The maxWidth
on ComboBox is overriding the minimum width that should be bubbling up from GridBox cells. @pixelzoom, do you feel comfortable with removing these usages of maxWidth
until we can implement a longer term solution here?
Not sure what the best way is to proceed. I would like to consult with @jonathanolson, but this will not be a priority issue until after maintenance releases are completed.
In the above commit, I applied the patch in https://github.com/phetsims/sun/issues/816#issuecomment-1352000872. Setting maxWidth
on a ComboBox is not essential, it's just a bit of insurance in case the ComboBox grows larger than expected. ComboBoxIitems should have maxWidth on any Text nodes (which these combo boxes do).
I don't know what the timeframe is for fixing this. But if it's going to be more than a few days, consider this temporary prohibition on maxWidth
in ComboBox.ts. It will identify other TypeScript sims that have this problem.
- export type ComboBoxOptions = SelfOptions & ParentOptions;
+ // maxWidth is buggy, see https://github.com/phetsims/sun/issues/816
+ export type ComboBoxOptions = SelfOptions & StrictOmit<ParentOptions, 'maxWidth'>;
I don't know what the timeframe is for fixing this. But if it's going to be more than a few days, consider this temporary prohibition on maxWidth in ComboBox.ts. It will identify other TypeScript sims that have this problem.
I took a look through usages and I found some sims that are indeed using maxWidth on their comboBox, but is not reproducing the same buggy behavior and eliminating maxWidth has other consequences. I'm not confident that I can use that patch without repercussions...
Edit: I'm going to keep looking through this to see if theres a good short term fix, but I'm not feeling confident in that with some of the use cases I'm seeing. Removing the blocks-publication label, as there is a fix if a sim is experiencing this problem.
This was actually a case where:
(1) You have something sizable (can get preferred sizes) like a ComboBox. (2) You don't turn off that sizability (e.g. no widthSizable: false, heightSizable: false, sizable: false that covers a specific dimension) (2) You put a maxWidth/maxHeight on that dimension. (3) You put the node inside a layout container (4) The container is configured to increase the size of the node if it has enough room (5) The size is attempted to be increased PAST the maxWidth/maxHeight provided.
So while it isn't just ComboBox, it also requires a lot of things going on to get to this buggy situation.
I added an assertion to catch this case, and fixed the 1 other place it happened (CCK).
@marlitas can you review?
Ahh okay. That is very tricky. That assertion looks very clear and fits well with the explanation you provided. Thanks for the investigation and fix here @jonathanolson. I believe this is ready to close.
@pixelzoom commented in https://github.com/phetsims/sun/issues/810, that he was seeing buggy behavior with ComboBox in Fourier:
Investigation showed that AlignBox's minimumWidth is different than it's child's minimum width. This seems very incorrect.
AlignBox minimumWidth = 135
GridBox minimumWidth = 148
It is worth noting that this bug is not seen in all implementations of ComboBox, however removing custom ComboBox options from Fourier did not resolve the problem either.