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

Add default values when tracking edits in list interface #9707

Merged
merged 2 commits into from Dec 1, 2021

Conversation

azrikahar
Copy link
Contributor

fixes #9538

Context

When we first click block in Markdown custom blocks, it works. But when we try to revert back to inline, nothing seems to happen.

WLKjlBftMB

Investigation

The update:model-value for the list form was modified in #8169 here:

function trackEdits(updatedValues: any) {
Object.assign(edits.value, updatedValues);
}

However due to the nature of "if input is the same as the default value", in this case the default is inline, the doesn't end up emitting box: inline here because the unset kicks in:

function emitValue(value: any) {
if (
(isEqual(value, props.initialValue) ||
(props.initialValue === undefined && isEqual(value, defaultValue.value))) &&
props.batchMode === false
) {
emit('unset', props.field);
} else {
emit('update:modelValue', value);
}
}

Hence the updatedValues in trackEdits() above never has the property box, so it stays as block.

Fix

Added defaults in case the updatedValues doesn't have specific properties, implying it should "revert" to the default value when we assign it to edits.value.

SqyDQba6l1

Also added a line to clear edits value when the drawer is closed.

@rijkvanzanten rijkvanzanten merged commit 3391ac9 into main Dec 1, 2021
@rijkvanzanten rijkvanzanten deleted the issue/9538 branch December 1, 2021 21:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdown text interface cannot change block/inline for custom block
2 participants