Skip to content

Commit

Permalink
Merge pull request #36207 from Krishna2323/krishna2323/issue/35761
Browse files Browse the repository at this point in the history
fix: Workspace highlighted member blinks when check/uncheck mark.
  • Loading branch information
marcochavezf authored Feb 12, 2024
2 parents b6ded25 + 9caf59a commit cb656a0
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ function BaseSelectionList<TItem extends User | RadioItem>(
* Logic to run when a row is selected, either with click/press or keyboard hotkeys.
*
* @param item - the list item
* @param shouldUnfocusRow - flag to decide if we should unfocus all rows. True when selecting a row with click or press (not keyboard)
*/
const selectRow = (item: TItem, shouldUnfocusRow = false) => {
const selectRow = (item: TItem) => {
// In single-selection lists we don't care about updating the focused index, because the list is closed after selecting an item
if (canSelectMultiple) {
if (sections.length > 1) {
Expand All @@ -191,20 +190,11 @@ function BaseSelectionList<TItem extends User | RadioItem>(
// we focus the first one after all the selected (selected items are always at the top).
const selectedOptionsCount = item.isSelected ? flattenedSections.selectedOptions.length - 1 : flattenedSections.selectedOptions.length + 1;

if (!shouldUnfocusRow) {
setFocusedIndex(selectedOptionsCount);
}

if (!item.isSelected) {
// If we're selecting an item, scroll to it's position at the top, so we can see it
scrollToIndex(Math.max(selectedOptionsCount - 1, 0), true);
}
}

if (shouldUnfocusRow) {
// Unfocus all rows when selecting row with click/press
setFocusedIndex(-1);
}
}

onSelectRow(item);
Expand Down Expand Up @@ -295,7 +285,7 @@ function BaseSelectionList<TItem extends User | RadioItem>(
isDisabled={isDisabled}
showTooltip={showTooltip}
canSelectMultiple={canSelectMultiple}
onSelectRow={() => selectRow(item, true)}
onSelectRow={() => selectRow(item)}
onDismissError={onDismissError}
shouldPreventDefaultFocusOnSelectRow={shouldPreventDefaultFocusOnSelectRow}
rightHandSideComponent={rightHandSideComponent}
Expand Down

0 comments on commit cb656a0

Please sign in to comment.