-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix(select): support floating labels with slotted content #31326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: major-9.0
Are you sure you want to change the base?
Changes from all commits
f7b1a82
5821084
8a3df75
108222a
5a47f9f
939b029
657ba03
9fdfc74
d5ecc50
4459f48
7a6f3ef
feafbf2
ecbe120
531ff9b
b7de667
64c9cfb
c822f1d
a4ec7e8
b21f895
8610c19
a27ba41
be5fdbb
e9d9c26
4575687
d106957
3205851
b5a1d65
ffe8326
9a7b423
ed00d80
3b31ce8
898363a
c1e8eeb
627adcd
2ad8063
a3eb13d
f448a13
50cbaa5
bc9aba8
497c29e
27a0ccb
eb1387a
a4900bf
9b800b1
9ffbb9f
22afd8e
6e7a770
c83ddb8
90cdaa7
e490f50
bfbedc9
275e0e5
79fb5a7
05937e1
d2ded42
4d4ca45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -118,14 +118,6 @@ | |
| --border-radius: 16px; | ||
| } | ||
|
|
||
| // Select Inner Wrapper | ||
| // ---------------------------------------------------------------- | ||
|
|
||
| :host(.select-label-placement-stacked) .select-wrapper-inner, | ||
| :host(.select-label-placement-floating) .select-wrapper-inner { | ||
| width: calc(100% - $select-md-icon-size - $select-icon-margin-start); | ||
| } | ||
|
Comment on lines
-121
to
-127
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could not find anywhere this is necessary after changing the icon structure. |
||
|
|
||
| // Select: Disabled | ||
| // ---------------------------------------------------------------- | ||
| // The select and label should use the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -154,36 +154,6 @@ button { | |
| color: inherit; | ||
| } | ||
|
|
||
| /** | ||
| * The select icon should be centered with | ||
| * the entire container not just the control | ||
| * with floating/stacked labels. | ||
| */ | ||
| :host(.select-label-placement-stacked) .select-icon, | ||
| :host(.select-label-placement-floating) .select-icon { | ||
| position: absolute; | ||
|
|
||
| height: 100%; | ||
| } | ||
|
|
||
| /** | ||
| * This positions the icon at the correct | ||
| * edge of the component with LTR and RTL | ||
| * text directions. The position mixin cannot be | ||
| * used here because the icon is in the Shadow DOM. | ||
| */ | ||
| :host(.select-ltr.select-label-placement-stacked) .select-icon, | ||
| :host(.select-ltr.select-label-placement-floating) .select-icon { | ||
| // stylelint-disable-next-line property-disallowed-list | ||
| right: var(--padding-end, 0); | ||
| } | ||
|
|
||
| :host(.select-rtl.select-label-placement-stacked) .select-icon, | ||
| :host(.select-rtl.select-label-placement-floating) .select-icon { | ||
| // stylelint-disable-next-line property-disallowed-list | ||
| left: var(--padding-start, 0); | ||
| } | ||
|
Comment on lines
-157
to
-185
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is no longer necessary using flex properties to center the icon vertically. |
||
|
|
||
| // Select Text | ||
| // -------------------------------------------------- | ||
| .select-text { | ||
|
|
@@ -237,7 +207,7 @@ button { | |
|
|
||
| flex-grow: 1; | ||
|
|
||
| align-items: center; | ||
| align-items: stretch; | ||
| justify-content: space-between; | ||
|
|
||
| height: inherit; | ||
|
|
@@ -270,23 +240,28 @@ button { | |
| transition: opacity 150ms cubic-bezier(0.4, 0, 0.2, 1); | ||
| } | ||
|
|
||
| .select-wrapper-inner { | ||
| /** | ||
| * The control must inherit specific flex properties | ||
| * so that it will be placed properly when justify | ||
| * or label-placement are set on the host. | ||
| */ | ||
| .select-control { | ||
| display: flex; | ||
|
|
||
| align-items: center; | ||
| flex: 1; | ||
|
|
||
| overflow: hidden; | ||
| } | ||
| flex-direction: inherit; | ||
|
|
||
| align-items: center; | ||
| justify-content: inherit; | ||
|
Comment on lines
+248
to
+256
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With slots populated,
The slot containers are siblings of the control now, so the wrapper's The No snapshot catches either, they all use a select with no slots. Both seem like issues to me, but I could understand if you want to defer this until later.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay well I broke some stuff trying to keep icon visible and tried about a hundred different approaches but none worked so here is the latest: 79fb5a7 And I made a follow-up (FW-7682) for showing icon when it collapses.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we get a slot screenshot for |
||
|
|
||
| :host(.select-label-placement-stacked) .select-wrapper-inner, | ||
| :host(.select-label-placement-floating) .select-wrapper-inner { | ||
| /** | ||
| * When using a stacked/floating label, the inner wrapper is | ||
| * stacked vertically under the label container. This line | ||
| * ensures that the inner wrapper fills all the remaining height | ||
| * of the component. | ||
| * The min-width is set to 0 to allow flex items to shrink below | ||
| * their content size. This enables the select text to collapse | ||
| * in width. We avoid overflow: hidden here because it will clip | ||
| * the floating label. | ||
| */ | ||
| flex-grow: 1; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| // Select Highlight | ||
|
|
@@ -390,6 +365,13 @@ button { | |
|
|
||
| align-items: center; | ||
|
|
||
| /** | ||
| * Allows the label to shrink below its intrinsic content width. | ||
| * Without this the label keeps its full width and can push the | ||
| * select and end slot outside the wrapper. | ||
| */ | ||
| min-width: 0; | ||
|
|
||
| /** | ||
| * Label text should not extend | ||
| * beyond the bounds of the select. | ||
|
|
@@ -410,6 +392,18 @@ button { | |
| pointer-events: none; | ||
| } | ||
|
|
||
| /** | ||
| * When start/end slots are added or removed, we temporarily | ||
| * disable the label transition to prevent the floating label | ||
| * from animating as its position is adjusted. | ||
| * | ||
| * This class is applied by the start container controller, so | ||
| * renaming it here requires renaming it there too. | ||
| */ | ||
| :host(.skip-label-transition) .label-text-wrapper { | ||
| transition: none; | ||
| } | ||
|
|
||
| /** | ||
| * We need to use two elements instead of | ||
| * one. The .label-text-wrapper is responsible | ||
|
|
@@ -448,6 +442,14 @@ button { | |
| .native-wrapper { | ||
| display: flex; | ||
|
|
||
| /** | ||
| * Give up space before the label does. Flexbox would otherwise take | ||
| * from both in proportion to their size and truncate the shorter | ||
| * label first. The factor is this large because the label truncates | ||
| * as soon as it loses any width at all, even a fraction of a pixel. | ||
| */ | ||
| flex-shrink: 100000; | ||
|
|
||
| align-items: center; | ||
|
|
||
| /** | ||
|
|
@@ -554,9 +556,18 @@ button { | |
| * down when the select is focused or has a value. | ||
| * | ||
| */ | ||
| :host(.select-label-placement-stacked) .select-wrapper, | ||
| :host(.select-label-placement-floating) .select-wrapper { | ||
| :host(.select-label-placement-stacked) .select-control, | ||
| :host(.select-label-placement-floating) .select-control { | ||
| flex-direction: column; | ||
|
|
||
| /** | ||
| * When using a stacked/floating label, the control is | ||
| * stacked vertically under the label container. This line | ||
| * ensures that the control fills all the remaining height | ||
| * of the component. | ||
| */ | ||
|
brandyscarney marked this conversation as resolved.
|
||
| flex-grow: 1; | ||
|
|
||
| align-items: start; | ||
| } | ||
|
|
||
|
|
@@ -583,15 +594,11 @@ button { | |
| } | ||
|
|
||
| /** | ||
| * Ensures the select does not | ||
| * overlap the label. | ||
| * Also ensure that the native wrapper | ||
| * takes up the remaining available height and width. | ||
| * Ensures that the native wrapper takes up the | ||
| * remaining available height and width. | ||
| */ | ||
| :host(.select-label-placement-stacked) .native-wrapper, | ||
| :host(.select-label-placement-floating) .native-wrapper { | ||
| @include margin(1px, 0, 0, 0); | ||
|
|
||
| flex-grow: 1; | ||
|
|
||
| width: 100%; | ||
|
|
@@ -616,27 +623,16 @@ button { | |
| * The placeholder should be hidden when the label | ||
| * is on top of the select. This prevents the label | ||
| * from overlapping any placeholder value. | ||
| * | ||
| * TODO(FW-5592): Remove :not(.label-floating) piece | ||
| */ | ||
| :host(.select-label-placement-floating:not(.label-floating)) .native-wrapper .select-placeholder { | ||
| :host(.select-label-placement-floating) .native-wrapper .select-placeholder { | ||
| opacity: 0; | ||
| } | ||
|
|
||
| /** | ||
| * We don't use .label-floating here because that would | ||
| * also include the case where the label is floating due | ||
| * to content in the start/end slot. We want the opacity | ||
| * to remain at the default in this case, since the select | ||
| * isn't being actively interacted with. | ||
| * | ||
| * TODO(FW-5592): Change entire selector to: | ||
| * :host(.label-floating.select-label-placement-floating) .native-wrapper .select-placeholder | ||
| * Show the placeholder when the label is floating. | ||
| */ | ||
| :host(.select-expanded.select-label-placement-floating) .native-wrapper .select-placeholder, | ||
| :host(.has-focus.select-label-placement-floating) .native-wrapper .select-placeholder, | ||
| :host(.has-value.select-label-placement-floating) .native-wrapper .select-placeholder { | ||
| opacity: 1; | ||
| :host(.label-floating.select-label-placement-floating) .native-wrapper .select-placeholder { | ||
| opacity: var(--placeholder-opacity); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -655,6 +651,17 @@ button { | |
| // Start/End Slots | ||
| // ---------------------------------------------------------------- | ||
|
|
||
| .select-start, | ||
| .select-end { | ||
| display: flex; | ||
|
|
||
| position: relative; | ||
|
|
||
| flex-shrink: 0; | ||
|
|
||
| align-items: center; | ||
| } | ||
|
|
||
| ::slotted([slot="start"]), ::slotted([slot="end"]) { | ||
| /** | ||
| * Prevent the slots from shrinking when the label and/or | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find anywhere this is necessary after changing the icon structure.