Skip to content

Commit

Permalink
Merge pull request #2827 from xiamiao1121/hotfix/date-picker/#2825
Browse files Browse the repository at this point in the history
fix(date-picker): 修复format传入函数,只有在type='weekrange'下生效
  • Loading branch information
solarjoker authored May 17, 2024
2 parents c4f48c1 + 924d493 commit db02632
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-cycles-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

fix(date-picker): 修复 format 传入函数,只有在 type='weekrange'情况下生效
5 changes: 5 additions & 0 deletions .changeset/warm-gorillas-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/date-picker": patch
---

fix: 修复 format 传入函数,只有在 type='weekrange'情况下生效
6 changes: 6 additions & 0 deletions packages/ui/date-picker/src/components/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const Input = ({
const [value, setValue] = useState<string | null>('')

useEffect(() => {
if (typeof format === 'function' && date) {
cacheValues.current = format(date)
setValue(cacheValues.current)
return
}

let vals = date && moment(date).format(realFormat)

if (type.includes('week') && date) {
Expand Down

0 comments on commit db02632

Please sign in to comment.