Skip to content

Fix default value handling on Tabs component without v-model

Erwan Rouchet requested to merge fix-tabs-default into master

Closes #963 (closed)

The project creation and edition page are the same component. This component uses a <Tabs> component to display a bunch of tabs to allow access to types, classes, allowed metadata and rights, but only the "Details" tab is shown for project creation. The component is invisible when there is only one tab.

When the Tabs component mounts, it tries to select the first tab, but if there is nothing, it selects '' (the default value). If there is something given as the value prop (using :value or v-model), then it selects it immediately. This is done using a bunch of watchers that ran in a weird order when not using v-model: when opening the project creation page, the component automatically selects the only tab, details, then another watcher triggers for an empty value, which re-selects '', so no tab is selected at all again.

This MR fixes a check on the select() method to ensure the empty value can only be picked when there are zero tabs, which would have caused a Error: Unknown tab '' when this bug occurs, prevents the value watcher from selecting nothing, and adds a bunch of tests to ensure the Tabs component behaves properly and the project creation page always displays something.

Merge request reports

Loading