-
Notifications
You must be signed in to change notification settings - Fork 0
fix(search-bar): Retain position in value combobox when multi-selecting #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(search-bar): Retain position in value combobox when multi-selecting #46
Conversation
Retain Position in Value Combobox When Multi-Selecting (Search Bar UX Improvements) This PR improves the behavior of the multi-select value combobox in the search bar, ensuring selected values retain their position and order during the selection process. Extensive changes are made to internal state management and rendering logic so that when users select or deselect multiple values (e.g., with checkboxes or keyboard), the position and order of selected options are preserved across interactions and after the combobox is closed and reopened. The UI also ensures focused options are maintained properly and improves input focus handling during multi-selection. Corresponding test cases have been added to verify correct value reordering and overall stability. Key Changes• Refactored selection state in Affected Areas• This summary was automatically generated by @propel-code-bot |
// Use the actual token location from the parser instead of indexOf to avoid | ||
// matching substrings (e.g., "artifact_bundle.assemble" inside "artifact_bundle.assemble.find_projects") | ||
const selected = text.charAt(item.value?.location.end.offset ?? 0) === ','; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[BestPractice]
Potential substring matching issue in selection detection:
// Use the actual token location from the parser instead of indexOf to avoid
// matching substrings (e.g., "artifact_bundle.assemble" inside "artifact_bundle.assemble.find_projects")
const selected = text.charAt(item.value?.location.end.offset ?? 0) === ',';
This fix is good, but there's still a potential issue: if item.value?.location.end.offset
is 0 (falsy), the fallback ?? 0
will use index 0, which may not be correct for the actual token position. Consider using a more explicit check:
const endOffset = item.value?.location?.end?.offset;
if (endOffset === undefined) {
// Handle case where location info is missing
continue; // or some other fallback logic
}
const selected = text.charAt(endOffset) === ',';
Context for Agents
[**BestPractice**]
Potential substring matching issue in selection detection:
```typescript
// Use the actual token location from the parser instead of indexOf to avoid
// matching substrings (e.g., "artifact_bundle.assemble" inside "artifact_bundle.assemble.find_projects")
const selected = text.charAt(item.value?.location.end.offset ?? 0) === ',';
```
This fix is good, but there's still a potential issue: if `item.value?.location.end.offset` is 0 (falsy), the fallback `?? 0` will use index 0, which may not be correct for the actual token position. Consider using a more explicit check:
```typescript
const endOffset = item.value?.location?.end?.offset;
if (endOffset === undefined) {
// Handle case where location info is missing
continue; // or some other fallback logic
}
const selected = text.charAt(endOffset) === ',';
```
File: static/app/components/searchQueryBuilder/tokens/filter/valueCombobox.tsx
Line: 149
TODO
Ticket: EXP-357
Copied from getsentry#101070
Original PR: getsentry#101070