-
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
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; | ||
| position: relative; | ||
|
|
||
| overflow: hidden; | ||
| } | ||
| flex: 1; | ||
|
|
||
| flex-direction: inherit; | ||
|
|
||
| align-items: center; | ||
| justify-content: inherit; | ||
|
|
||
| :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 | ||
|
|
@@ -554,9 +529,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 inner wrapper is | ||
| * stacked vertically under the label container. This line | ||
| * ensures that the inner wrapper fills all the remaining height | ||
| * of the component. | ||
| */ | ||
| flex-grow: 1; | ||
|
|
||
| align-items: start; | ||
| } | ||
|
|
||
|
|
@@ -583,15 +567,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 +596,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 +624,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.