Skip to content

fix(GlFilteredSearch): Token activation after destruction

Mark Florian requested to merge 1679-fix-token-click into main

What does this MR do?

This makes more intuitive the behaviour of the active token after a token has been destroyed.

The previous behaviour was to always activate the previous token, unless the token being deleted is the first one. This had two undesirable effects:

  1. If you click the close x button on a token, the previous token's value would now become active. This likely isn't what you want, and is what #1679 (closed) is about.
  2. If an active token is not the first token, and you click the close x on the first token, the currently active token changes, because all tokens got shifted down by one index.

The new logic tries to maintain the active states of the tokens as-is, unless it's not possible, or the way the token was destroyed implies the previous token should be activated. That happens when a search term is destroyed by pressing backspace once it's empty.

Addresses #1679 (closed).

Screenshots

User interaction Before After
Backspacing to activate previous token backspacing_before backspacing_after
Destroying earlier token than active one destroying_earlier_before destroying_earlier_after
Destroying later token than active one destroying_later_before destroying_later_after

Does this MR meet the acceptance criteria?

Conformity

  • [-] Code review guidelines.
  • [-] GitLab UI's contributing guidlines.
  • If it changes a Pajamas-compliant component's look & feel, the MR has been reviewed by a UX designer.
  • [-] If it changes GitLab UI's documentation guidelines, the MR has been reviewed by a Technical Writer.
  • If the MR changes a component's API, integration MR(s) have been opened in the following projects to ensure that the @gitlab/ui package can be upgraded quickly after the changes are released:
  • Added the ~"component:*" label(s) if applicable.
Edited by Mark Florian

Merge request reports