If I'm using CdxLookup in a form to edit existing data, the v-model:selected and :initial-input-value properties may be set when the form loads, but there won't be a matching menu item unless it is specifically created or retrieved.
However, there being no menu-items causes unexpected behavior when the user blanks the input. Because the following if-clause:
function onUpdateInput( newVal: string|number ) { // If there is a selection and it doesn't match the new value, clear it. if ( selectedMenuItem.value && selectedMenuItem.value.label !== newVal && selectedMenuItem.value.value !== newVal ) { modelWrapper.value = null; } // [...]
wont execute (no menu items), hence the @update:selected event won't trigger with null, and thus failing to signal that the selection has been removed.
This was part of the cause for T370326.
Acceptance criteria
- The selection is cleared when the input changes and no longer matches the selection, whether or not there is a matching menu item for the selection