Skip to content

Commit

Permalink
fix(material): avoid reset date input
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrgm committed Jul 25, 2023
1 parent b128272 commit a95d129
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-bees-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@suid/material": patch
---

Fix controlled `InputBase` component with date type
13 changes: 5 additions & 8 deletions packages/material/src/InputBase/InputBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,6 @@ const InputBase = $.component(function InputBase({
});
});

const valueProp = () =>
inputRef.ref instanceof HTMLInputElement
? inputRef.ref.type === "date"
? undefined
: value()
: value();

createEffect<boolean>((loadDefaultValue) => {
const input = inputRef.ref as HTMLInputElement;
if (isControlled || loadDefaultValue) {
Expand Down Expand Up @@ -595,7 +588,11 @@ const InputBase = $.component(function InputBase({
placeholder={props.placeholder}
readOnly={props.readOnly}
required={fcs.required}
value={valueProp()}
{...(props.type !== "date" && {
get value() {
return value();
},
})}
{...({
rows: props.rows,
} as any)}
Expand Down

0 comments on commit a95d129

Please sign in to comment.