Skip to content

Commit

Permalink
fix(Editable): maxLength not working (#1325)
Browse files Browse the repository at this point in the history
* ✨ feat: add maxLength to input field

* 🐛 fix: proper prop casing

Co-authored-by: zernonia <[email protected]>

* test: add test case for maxLength props

---------

Co-authored-by: zernonia <[email protected]>
  • Loading branch information
iammola and zernonia authored Oct 1, 2024
1 parent f76856a commit 8578dc9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/radix-vue/src/Editable/Editable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,14 @@ describe('editable', () => {

expect(preview).toHaveStyle({ visibility: 'hidden' })
})

it('should prevent user input text more than given `maxLength`', async () => {
const { input, edit } = setup({ editableProps: { maxLength: 10 } })

await userEvent.click(edit)

await userEvent.type(input, 'lorem ipsum dolor sit amet')

expect(input).toHaveValue('lorem ipsu')
})
})
1 change: 1 addition & 0 deletions packages/radix-vue/src/Editable/EditableInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function handleSubmitKeyDown(event: KeyboardEvent) {
:value="context.modelValue.value"
:placeholder="placeholder"
:disabled="disabled"
:maxlength="context.maxLength.value"
:data-disabled="disabled ? '' : undefined"
:data-readonly="context.readonly.value ? '' : undefined"
:readonly="context.readonly.value"
Expand Down

0 comments on commit 8578dc9

Please sign in to comment.