Skip to content

Commit

Permalink
fix(Editable): allow space inputs when submitMode is enter (#1013)
Browse files Browse the repository at this point in the history
* fix: allow more space inputs in editable

* refactor(Editable): remove space from allowed keys and ignore meta key

* docs(Editable): update docs

---------

Co-authored-by: Eduard Predescu <eduard.florin.predescu@gmail.com>
  • Loading branch information
ricketyBridges and epr3 committed Jun 20, 2024
1 parent 52100df commit 87cfcbb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
8 changes: 0 additions & 8 deletions docs/content/components/editable.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ Contains the cancel trigger of the editable component.
keys: ['Tab'],
description: `<span>When focus moves onto the editable field, switches into the editable mode if the <Code>activation-mode</Code> is set to focus.</span>`
},
{
keys: ['Space'],
description:`
<span>
If the <Code>submit-mode</Code> is set to <Code>enter</Code> or <Code>both</Code>, it submits the changes.
</span>
` ,
},
{
keys: ['Enter'],
description:`
Expand Down
2 changes: 1 addition & 1 deletion packages/radix-vue/src/Editable/EditableInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ watch(context.isEditing, (value) => {
})
function handleSubmitKeyDown(event: KeyboardEvent) {
if ((context.submitMode.value === 'enter' || context.submitMode.value === 'both') && (event.key === kbd.ENTER || event.key === kbd.SPACE) && !event.shiftKey)
if ((context.submitMode.value === 'enter' || context.submitMode.value === 'both') && event.key === kbd.ENTER && !event.shiftKey && !event.metaKey)
context.submit()
}
</script>
Expand Down

0 comments on commit 87cfcbb

Please sign in to comment.