Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/blue-wasps-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@spectrum-css/checkbox": patch
---

Adds a `::before` pseudo element to properly target the `.spectrum-Checkbox-input:checked + .spectrum-Checkbox-box` element. The selector update, specifically in the invalid+checked+hover state should now get the proper error background color, as opposed to the default background color.
2 changes: 1 addition & 1 deletion components/checkbox/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
".spectrum-Checkbox.is-invalid.is-indeterminate:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before",
".spectrum-Checkbox.is-invalid.is-indeterminate:hover .spectrum-Checkbox-label",
".spectrum-Checkbox.is-invalid:hover .spectrum-Checkbox-box:before",
".spectrum-Checkbox.is-invalid:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box",
".spectrum-Checkbox.is-invalid:hover .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box:before",
".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input",
".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input:checked:disabled + .spectrum-Checkbox-box:before",
".spectrum-Checkbox.is-readOnly .spectrum-Checkbox-input:checked:disabled ~ .spectrum-Checkbox-label",
Expand Down
3 changes: 2 additions & 1 deletion components/checkbox/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
}

&:hover {
.spectrum-Checkbox-input:checked + .spectrum-Checkbox-box,
.spectrum-Checkbox-input:checked + .spectrum-Checkbox-box::before,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the reason these styles weren't working is because we need the .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box::before selector.

As I was looking through the other hover styles, trying to understand why they were working but this one wasn't, it seems like every other hover instance is referencing the entire .spectrum-Checkbox-input:checked + .spectrum-Checkbox-box::before selector. Am I missing anything?

I'm not sure I can correct this bug without it, but I'm very open to other ideas and happy to brainstorm!

.spectrum-Checkbox-box::before {
border-color: var(--highcontrast-checkbox-color-hover, var(--mod-checkbox-invalid-color-hover, var(--spectrum-checkbox-invalid-color-hover)));
}
Expand Down Expand Up @@ -280,6 +280,7 @@
}
}

/* TODO: Because this selector was moved to the default variant's styles, this selector block can be deleted when it is safe to make changes to selectors. */
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a note that we could refactor in the future. I experimented with copying this selector into the default .spectrum-Checkbox block, around line 168, and commented out this selector at line 287 nested within the --emphasized variant. The styles seemed to cascade correctly in both variants.

I thought that was too much repetition WITH new selectors, so I opted instead for just reorganizing the selector in the default block.

/* Invalid Hover States */
&.is-invalid:hover {
&.is-indeterminate .spectrum-Checkbox-box,
Expand Down
Loading