Skip to content

Commit

Permalink
fix: number input mutation timing
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Nov 3, 2023
1 parent f21fdbb commit 7751c72
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-pugs-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zag-js/number-input": patch
---

Fix issue where "." cannot be entered due to virtual dom timing between frameworks
3 changes: 1 addition & 2 deletions packages/machines/number-input/src/number-input.machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,10 +376,9 @@ export function machine(userContext: UserDefinedContext) {
// record cursor position before updating input value
const sel = recordCursor(inputEl!)

dom.setValue(inputEl, inputValue)

// restore cursor position after updating input value
raf(() => {
dom.setValue(inputEl, inputValue)
restoreCursor(inputEl!, sel)
})
},
Expand Down

4 comments on commit 7751c72

@vercel
Copy link

@vercel vercel bot commented on 7751c72 Nov 3, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 7751c72 Nov 3, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

zag-vue – ./examples/vue-ts

zag-vue-git-main-chakra-ui.vercel.app
zag-vue-chakra-ui.vercel.app
zag-vue.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 7751c72 Nov 3, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

zag-solid – ./examples/solid-ts

zag-solid.vercel.app
zag-solid-git-main-chakra-ui.vercel.app
zag-solid-chakra-ui.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 7751c72 Nov 3, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

zag-nextjs – ./examples/next-ts

zag-two.vercel.app
zag-nextjs-git-main-chakra-ui.vercel.app
zag-nextjs-chakra-ui.vercel.app

Please sign in to comment.