Skip to content

Commit

Permalink
docs(Editable): add Change only on submit example
Browse files Browse the repository at this point in the history
  • Loading branch information
hrynevychroman committed Jan 3, 2025
1 parent 194bf4b commit e14f035
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions docs/content/components/editable.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,40 @@ Contains the cancel trigger of the editable component.

<!-- @include: @/meta/EditableCancelTrigger.md -->

## 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
<script setup lang="ts">
const defaultValue = ref('Default value')
function handleSubmit(label?: string) {
defaultValue.value = label
}
</script>
<template>
<template>
<EditableRoot
:default-value="defaultValue"
@submit="handleSubmit"
>
<EditableArea>
<EditablePreview />
<EditableInput />
</EditableArea>
<EditableEditTrigger />
<EditableSubmitTrigger />
<EditableCancelTrigger />
</EditableRoot>
</template>
</template>
```

## Accessibility

### Keyboard Interactions
Expand Down

0 comments on commit e14f035

Please sign in to comment.