Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(Editable): add Change only on submit example #1538

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
Copy link
Member

Choose a reason for hiding this comment

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

how about using :model-value instead of default-value? 🤔

@submit="handleSubmit"
>
<EditableArea>
<EditablePreview />
<EditableInput />
</EditableArea>
<EditableEditTrigger />
<EditableSubmitTrigger />
<EditableCancelTrigger />
</EditableRoot>
</template>
</template>
```

## Accessibility

### Keyboard Interactions
Expand Down
Loading