Skip to content

fix(form): compute isMin from min, not max - #80

Open
173787247 wants to merge 1 commit into
shigma:mainfrom
173787247:form-ismin-from-min
Open

173787247 wants to merge 1 commit into
shigma:mainfrom
173787247:form-ismin-from-min

Conversation

@173787247

Copy link
Copy Markdown

isMin is used to disable the delete button in the group and table extensions:

packages/form/src/extensions/group.vue:40   :class="{ disabled: disabled || isMin }" @click="del(index)"
packages/form/src/extensions/table.vue:89   :class="{ disabled: isMin }"

but it is computed from meta.max:

const isMax = computed(() => entries.value.length >= props.schema.meta.max)
const isMin = computed(() => entries.value.length >= props.schema.meta.max)

Two consequences:

  • with both bounds set (Schema.array(X).min(2).max(5)) — at two entries isMin is
    2 >= 5 = false, so the button stays enabled and entries can be removed past min.
  • with only max set (Schema.array(X).max(3)) — at three entries isMin is
    3 >= 3 = true, so the button is disabled and entries cannot be removed at all,
    even though there is no lower bound.

min/max are the only two bounds and isMax already reads max, so the fix is the
comparison operand.

`isMin` gates the delete button in the group and table extensions, but it was
computed from `meta.max`. Two consequences:

- with both bounds set, the button stays enabled below `min`, so entries can be
  removed past the lower bound
- with only `max` set, the button is disabled as soon as the array is full, so
  entries cannot be removed at all

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant