From e14f035a76b4582f7c9b28f5e8f76dc44c94a0c8 Mon Sep 17 00:00:00 2001 From: hrynevychroman Date: Fri, 3 Jan 2025 13:28:41 +0200 Subject: [PATCH 1/5] docs(Editable): add `Change only on submit` example --- docs/content/components/editable.md | 34 +++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/content/components/editable.md b/docs/content/components/editable.md index b115ce59c..9286a7fc4 100644 --- a/docs/content/components/editable.md +++ b/docs/content/components/editable.md @@ -146,6 +146,40 @@ Contains the cancel trigger of the editable component. +## Examples + +### Change only on submit + +Use the `default-value` prop to define starting value and `@submit` emit to handle the submit event. +This is useful when you want to change the value only when the user submits the changes and have `auto-resize` working properly. + +```vue line=12-13 + + + +``` + ## Accessibility ### Keyboard Interactions From 805ce2b355497d651e257c860b2a3490bb73c1e5 Mon Sep 17 00:00:00 2001 From: hrynevychroman Date: Sat, 18 Jan 2025 12:56:54 +0200 Subject: [PATCH 2/5] feat(editable): update flow to update:model-value only on submit --- packages/radix-vue/src/Editable/EditableInput.vue | 4 ++-- packages/radix-vue/src/Editable/EditableRoot.vue | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/radix-vue/src/Editable/EditableInput.vue b/packages/radix-vue/src/Editable/EditableInput.vue index c1e276a21..a4a898d49 100644 --- a/packages/radix-vue/src/Editable/EditableInput.vue +++ b/packages/radix-vue/src/Editable/EditableInput.vue @@ -53,7 +53,7 @@ function handleSubmitKeyDown(event: KeyboardEvent) { diff --git a/packages/radix-vue/src/Editable/EditableRoot.vue b/packages/radix-vue/src/Editable/EditableRoot.vue index 1b445be9f..a005356e4 100644 --- a/packages/radix-vue/src/Editable/EditableRoot.vue +++ b/packages/radix-vue/src/Editable/EditableRoot.vue @@ -13,6 +13,7 @@ type EditableRootContext = { maxLength: Ref disabled: Ref modelValue: Ref + inputValue: Ref placeholder: Ref<{ edit: string, preview: string }> isEditing: Ref submitMode: Ref @@ -75,7 +76,7 @@ export const [injectEditableRootContext, provideEditableRootContext] +By default the component will submit when `blur` event triggers. We can modify the `submit-mode` prop to alter this behavior. +In this case, we want to submit only when user click on `EditableSubmitTrigger`, so we change the submit mode to `none`. +```vue line=2,8 ```