Skip to content

Commit

Permalink
fix(material): pass always value property in SwitchBase component
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Apr 27, 2022
1 parent 13e7754 commit 938d054
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/real-bananas-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@suid/material": patch
---

Pass always value property in `SwitchBase` component
9 changes: 2 additions & 7 deletions packages/material/src/internal/SwitchBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ const SwitchBase = $.component(function SwitchBase({

const classes = $.useClasses(ownerState);
const element = createRef(() => props.inputRef);

const inputValue = () => {
if (props.type === "checkbox") {
return props.value ?? formControlLabel?.value;
}
};
const inputValue = () => props.value ?? formControlLabel?.value;

createEffect(() => {
if (typeof props.defaultChecked === "boolean")
Expand Down Expand Up @@ -208,7 +203,7 @@ const SwitchBase = $.component(function SwitchBase({
ownerState={ownerState}
tabIndex={props.tabIndex}
type={props.type}
{...{ value: inputValue() }}
value={inputValue()}
{...(props.inputProps || {})}
/>
{checked() ? props.checkedIcon : props.icon}
Expand Down

0 comments on commit 938d054

Please sign in to comment.