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

bug(checkbox): added missing readonly prop value #3859

Merged
merged 12 commits into from
Dec 14, 2023
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ executors:
parameters:
current_golden_images_hash:
type: string
default: 0726ebbd02b4064ebab9683ec4e3ae00163a21ed
default: 0214646d25bd039099827dde1d6b00663e084836
wireit_cache_name:
type: string
default: wireit
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"@spectrum-web-components/shared": "^0.40.1"
},
"devDependencies": {
"@spectrum-css/checkbox": "^7.0.11"
"@spectrum-css/checkbox": "^8.0.3"
},
"types": "./src/index.d.ts",
"customElements": "custom-elements.json",
Expand Down
2 changes: 2 additions & 0 deletions packages/checkbox/src/CheckboxMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface CheckboxElement {
handleChange(): void;
inputElement: HTMLInputElement;
name?: string;
readonly?: boolean;
}

export function CheckboxMixin<T extends Constructor<ReactiveElement>>(
Expand Down Expand Up @@ -74,6 +75,7 @@ export function CheckboxMixin<T extends Constructor<ReactiveElement>>(
name=${ifDefined(this.name || undefined)}
type="checkbox"
.checked=${this.checked}
?disabled=${this.readonly}
@change=${this.handleChange}
/>
`;
Expand Down
13 changes: 7 additions & 6 deletions packages/checkbox/src/spectrum-checkbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,10 @@ governing permissions and limitations under the License.
position: relative;
}
#box:before {
block-size: var(
--mod-checkbox-control-size,
var(--spectrum-checkbox-control-size)
);
border-color: var(
--highcontrast-checkbox-color-default,
var(
Expand All @@ -720,7 +724,7 @@ governing permissions and limitations under the License.
content: '';
display: block;
forced-color-adjust: none;
height: var(
inline-size: var(
--mod-checkbox-control-size,
var(--spectrum-checkbox-control-size)
);
Expand All @@ -737,10 +741,6 @@ governing permissions and limitations under the License.
var(--spectrum-checkbox-animation-duration)
)
ease-in-out;
width: var(
--mod-checkbox-control-size,
var(--spectrum-checkbox-control-size)
);
z-index: 0;
}
#box:after {
Expand All @@ -756,7 +756,8 @@ governing permissions and limitations under the License.
);
content: '';
display: block;
inset: 0;
inset-block: 0;
inset-inline: 0;
margin: var(
--mod-checkbox-focus-indicator-gap,
var(--spectrum-checkbox-focus-indicator-gap)
Expand Down
6 changes: 5 additions & 1 deletion packages/checkbox/test/checkbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,11 @@ describe('Checkbox', () => {

expect(el.checked).to.be.true;
});

it('should recognize readonly property', async () => {
const el: Checkbox = await fixture('<sp-checkbox></sp-checkbox>');
expect(el.readonly).to.not.throw;
expect(el.readonly).to.be.a('boolean');
});
it('maintains its value when [readonly]', async () => {
const el = await fixture<Checkbox>(html`
<sp-checkbox id="checkbox0" checked readonly>Component</sp-checkbox>
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6797,10 +6797,10 @@
resolved "https://registry.yarnpkg.com/@spectrum-css/card/-/card-6.2.1.tgz#8a6d5906483e9b2fd5e3debbc9d61ffee0ec53a0"
integrity sha512-piawqolhedkdudq6TOB1PopRvFtFkaOWiDGlscPaHLGD4DsmLSmlFp6YRl/AmmD6vnPQs+mq/EUmNFamzUroAQ==

"@spectrum-css/checkbox@^7.0.11":
version "7.0.11"
resolved "https://registry.yarnpkg.com/@spectrum-css/checkbox/-/checkbox-7.0.11.tgz#1dea027dce45b575c8cdde7b020aeba2207981fe"
integrity sha512-L7B/fHaMo9+zdjJROHsYMlxN4huPEnnJjTR/qDnA/0y46InGIBipNCDa514Li3gL61qMeMvJCiRW3W+cDXOpxw==
"@spectrum-css/checkbox@^8.0.3":
version "8.0.3"
resolved "https://registry.yarnpkg.com/@spectrum-css/checkbox/-/checkbox-8.0.3.tgz#d03088d5091a0b401bdc9938e625bf47244b924d"
integrity sha512-E4XIDl/nx16Z1ITdjgIbe9d2cgSVCzS5l31NJmzHzwnR9LK11j72FnOjclXmVTmaTQa9vkaS6InC0hOaROrxvg==

"@spectrum-css/clearbutton@^5.0.5":
version "5.0.12"
Expand Down
Loading