Skip to content
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

[Backport 1.x] Fix combobox appearance when compressed and in-group #1372

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions src/components/combo_box/_combo_box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@
&.ouiComboBox__inputWrap-isLoading.ouiComboBox__inputWrap-isClearable {
@include ouiFormControlLayoutPadding(3); /* 2 */
}

&--inGroup#{&}--compressed {
height: $ouiFormControlLayoutGroupInputCompressedHeight; /* 2 */
line-height: $ouiFormControlLayoutGroupInputCompressedHeight; /* 2 */

.ouiComboBoxPill,
.ouiComboBoxPill + .ouiComboBoxPill {
margin: $ouiSizeXS $ouiSizeXS 0 0;
}

.ouiComboBoxPill--plainText {
line-height: calc($ouiSizeL - 2px);
}
}
}

/**
Expand Down Expand Up @@ -138,7 +152,19 @@
}
}

.ouiFormControlLayout--group {
.ouiComboBox__input {
height: ($ouiSizeXL - 2px);
}
}

&.ouiComboBox--compressed {
.ouiFormControlLayout--group {
.ouiComboBox__input {
height: $ouiFormControlLayoutGroupInputCompressedHeight;
}
}

.ouiComboBox__inputWrap {
line-height: $ouiFormControlCompressedHeight; /* 2 */
padding-top: 0;
Expand All @@ -165,13 +191,6 @@
}
}

// Overrides the top and bottom padding of 8px with ouiFormControlLayout--group
// when append/prepend is enabled, original top, bottom padding was 1px
.ouiFormControlLayout--group {
padding-top: 0;
padding-bottom: 0;
}

// Overrides line-height of 16px coming from ouiFormControlLayout--group .ouiText
.ouiFormControlLayout--group .ouiText {
// sass-lint:disable-block no-important
Expand Down
30 changes: 30 additions & 0 deletions src/components/combo_box/combo_box_input/_combo_box_pill.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,44 @@
line-height: $ouiSizeL - 2px;
vertical-align: baseline;

&.ouiBadge {
// A badge adds 1px border around the pill
line-height: $ouiSizeL - 4px;
}

&,
& + & /* 1 */ {
margin: $ouiSizeXS;
}

// In a group, reduce top and left margins and increase right margin by 1px
.ouiFormControlLayout--group &,
.ouiFormControlLayout--group & + & /* 1 */ {
margin: ($ouiSizeXS - 1px) ($ouiSizeXS + 1px) $ouiSizeXS ($ouiSizeXS - 1px);
}

&.ouiBadge,
&.ouiBadge + &.ouiBadge /* 1 */ {
margin: ($ouiSizeXS + 1px) $ouiSizeXS;
}

.ouiComboBox--compressed &,
.ouiComboBox--compressed & + & /* 1 */ {
margin: $ouiSizeXS $ouiSizeXS 0 0;
line-height: calc($ouiSizeL - 2px);
}

// In a group, reduce top and left margins and increase right margin by 1px
.ouiComboBox--compressed .ouiFormControlLayout--group &,
.ouiComboBox--compressed .ouiFormControlLayout--group & + & /* 1 */ {
margin: ($ouiSizeXS - 1px) ($ouiSizeXS + 1px) 0 -1px;
}

.ouiComboBox--compressed &.ouiBadge,
.ouiComboBox--compressed &.ouiBadge + &.ouiBadge /* 1 */ {
margin: ($ouiSizeXS + 1px) $ouiSizeXS 0 0;
// A badge adds 1px border around
line-height: calc($ouiSizeL - 4px);
}

&--plainText {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
.ouiText {
background-color: $ouiFormInputGroupLabelBackground;
padding: $ouiFormControlPadding;
line-height: $ouiSize !important;
line-height: calc($ouiSize - 2px) !important;
cursor: default !important; // pointer cursor on some form labels but not others is confusing

// If the next sibling is not the input, pull it closer to the text to reduce space
Expand Down
Loading