Incorrect key generation logic in GlFilteredSearch causes bad behaviour
(Originally found in #1651 (comment 886114328).)
If two consecutive tokens have the same type
(e.g., two Label
tokens) and you remove the first, the second becomes activated.
What should happen is that no token is made active as a result of that click on the x
button.
Screen_Recording_2022-03-23_at_19.48.51
Try it out yourself on this page: https://gitlab.com/gitlab-com/people-group/hiring-processes/-/issues?sort=updated_asc&state=opened&label_name[]=Shadowing&label_name[]=Frontend+Technical+Interviewer
At first glance !2705 (merged) should have fixed this, but it's actually a different bug! The cause of this one is inadequate key
calculation. Here's a breakdown of the cause of this bug:
- Use clicks
x
to remove first token - Token is removed, remaining tokens shift down one index
-
Next token now has the same
key
(e.g.,label-0
) as the token just removed, so the DOM for the old token is reused, even though its a different actual token - This mousedown handler now triggers for the wrong token, which incorrectly activates it
Edited by Mark Florian