Skip to content

Commit 9a8b7be

Browse files
committed
feat(combobox): updating disabled styles
1 parent a42d574 commit 9a8b7be

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

.changeset/new-doors-fold.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@spectrum-css/combobox": minor
33
---
44

5-
Combobox now includes a `read-only` state. Add the `is-readOnly` class to the Combobox to enable this feature.
5+
Combobox now includes a `read-only` state. Add the `is-readOnly` class to the Combobox to enable this feature. By doing so, this also activates the `readonly` attribute in the `Textfield` component. To ensure the intended user experience please make sure the readonly state in the textfield is enabled by adding the `is-readOnly` class and `readonly` attribute on the input element for this component as well.

components/combobox/index.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@
240240
background-color: var(--mod-textfield-background-color-disabled, var(--spectrum-combobox-readonly-background-color-disabled));
241241
border-color: transparent;
242242
color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-combobox-readonly-text-color-disabled)));
243+
244+
&:hover {
245+
background-color: var(--mod-textfield-background-color-disabled, var(--spectrum-combobox-readonly-background-color-disabled));
246+
}
243247
}
244248
}
245249
}
@@ -412,14 +416,14 @@
412416
border-block-end: var(--mod-combobox-border-width, var(--spectrum-combobox-border-width)) solid var(--mod-combobox-readonly-input-border-color, var(--spectrum-combobox-readonly-input-border-color));
413417
}
414418

419+
&.is-invalid > .spectrum-Combobox-input:read-only {
420+
border-color: var(--highcontrast-textfield-border-color-invalid-default, var(--mod-textfield-border-color-invalid-default, var(--spectrum-combobox-readonly-border-color-invalid-default)));
421+
}
422+
415423
&.is-disabled .spectrum-Combobox-input:read-only {
416424
color: var(--highcontrast-textfield-text-color-disabled, var(--mod-textfield-text-color-disabled, var(--spectrum-combobox-readonly-text-color-disabled)));
417425
border-color: var(--mod-textfield-border-color-disabled, var(--spectrum-combobox-border-color-disabled));
418426
}
419-
420-
&.is-invalid > .spectrum-Combobox-input:read-only {
421-
border-color: var(--highcontrast-textfield-border-color-invalid-default, var(--mod-textfield-border-color-invalid-default, var(--spectrum-combobox-readonly-border-color-invalid-default)));
422-
}
423427
}
424428
}
425429

components/combobox/metadata/metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
".spectrum-Combobox.is-keyboardFocused .spectrum-Combobox-button.is-invalid:not(:disabled, .spectrum-PickerButton--quiet)",
6464
".spectrum-Combobox.is-keyboardFocused .spectrum-Combobox-button:not(:disabled, .is-invalid, .spectrum-PickerButton--quiet)",
6565
".spectrum-Combobox.is-readOnly.is-disabled:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only",
66+
".spectrum-Combobox.is-readOnly.is-disabled:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only:hover",
6667
".spectrum-Combobox.is-readOnly.is-invalid:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only",
6768
".spectrum-Combobox.is-readOnly:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only",
6869
".spectrum-Combobox.is-readOnly:not(.spectrum-Combobox--quiet) .spectrum-Combobox-input:read-only:hover",

components/combobox/stories/combobox.stories.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Template, VariantGroup } from "./template.js";
1818
* - `.spectrum-Combobox-textfield` is required on the Textfield outer element (`.spectrum-Textfield`)
1919
* - `.spectrum-Combobox-input` is required on the `<input>` element inside of Textfields (`.spectrum-Textfield-input`)
2020
* - `.spectrum-Combobox-button` is required on the FieldButton (`.spectrum-ActionButton spectrum-ActionButton--sizeM`)
21-
*
21+
*
2222
* ### Indicating validity and focus
2323
*
2424
* Validity and focus must be bubbled up to the parent so descendants siblings can be styled. Implementations should add the following classes to the `.spectrum-Combobox` parent class in the following situations:
@@ -171,7 +171,7 @@ QuietGroup.parameters = {
171171
};
172172

173173
/**
174-
* Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made.
174+
* Comboboxes have a read-only option for when content in the disabled state still needs to be shown. This allows for content to be copied, but not interacted with or changed. A combobox does not have a read-only option if no selection has been made. To enable this feature, add `isReadOnly` class to the Combobox. Then within the Textfield component add `isReadOnly` class and `readonly` attribute to the `<input>`.
175175
*/
176176
export const ReadOnly = Template.bind({});
177177
ReadOnly.tags = ["!dev"];

components/combobox/stories/template.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export const Template = ({
118118
FieldLabel({
119119
size,
120120
label: fieldLabelText,
121+
isDisabled,
121122
customStyles: { "max-inline-size": "100px"},
122123
alignment: fieldLabelPosition === "left" && "left",
123124
}, context)

0 commit comments

Comments
 (0)