Skip to content

Commit 1c4a540

Browse files
authored
Fix Field-field shrink behavior (#2176)
* Fix Field-field shrink behavior * handle default width * remove erroneous import * Apply to both side label and position Top * revert change * Pushing to work on as a group * Only apply our size in forms for search within picker * Remove wrapper we added * Reverting so that things continue to work as they are on main * revert searchwithin in forms work * save point * reverting field once more * missed one instance of wrapper * remove extra unneeded class
1 parent ad58820 commit 1c4a540

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

packages/@adobe/spectrum-css-temp/components/fieldlabel/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ governing permissions and limitations under the License.
8888

8989
.spectrum-Field-field {
9090
flex: 1;
91+
/* Setting `flex: 1;` is equivalent to `flex: 1 1 0;`, which means we expect to be able to shrink
92+
* To be able to shrink, we must have a min-width that isn't 'auto' */
93+
min-width: 0;
9194
}
9295

9396
.spectrum-Field-field--multiline {

packages/@adobe/spectrum-css-temp/components/searchwithin/index.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ governing permissions and limitations under the License.
6464
}
6565
}
6666
}
67+
68+
/* this is specific to handling default width */
69+
.spectrum-SearchWithin-container {
70+
/* ensure we have higher specificity than .spectrum-Field */
71+
&.spectrum-SearchWithin-container {
72+
/* override the default width of the field container, only with labelPosition=top. */
73+
--spectrum-field-default-width: var(--spectrum-global-dimension-size-3000);
74+
min-inline-size: var(--spectrum-global-dimension-size-3000);
75+
}
76+
}

packages/@react-spectrum/searchwithin/chromatic/SearchWithin.chromatic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const Template: Story<SpectrumSearchWithinProps> = (args) => (
8181

8282
// Chromatic can't handle the size of the side label story so removed some extraneous props that don't matter for side label case.
8383
const TemplateSideLabel: Story<SpectrumSearchWithinProps> = (args) => (
84-
<Grid columns={repeat(2, '1fr')} autoFlow="row" gap="size-200" width={900}>
84+
<Grid columns={repeat(2, '1fr')} autoFlow="row" gap="size-200">
8585
{combinations.map(c => {
8686
let key = Object.keys(c).map(k => shortName(k)).join(' ');
8787
if (!key) {

packages/@react-spectrum/searchwithin/src/SearchWithin.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ function SearchWithin(props: SpectrumSearchWithinProps, ref: FocusableRef<HTMLEl
8080
<Field
8181
{...props}
8282
labelProps={labelProps}
83-
ref={domRef}>
83+
ref={domRef}
84+
wrapperClassName={classNames(
85+
styles,
86+
'spectrum-SearchWithin-container'
87+
)}>
8488
<div
8589
role="group"
8690
aria-labelledby={labelProps.id || ariaLabel}

0 commit comments

Comments
 (0)