Skip to content

Commit

Permalink
Merge pull request #41933 from Krishna2323/krishna2323/issue/41890
Browse files Browse the repository at this point in the history
fix: Category - Unable to select disabled category with keyboard.
  • Loading branch information
marcaaron authored May 10, 2024
2 parents 59b4f1a + a33c095 commit e1ebfd0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function BaseSelectionList<TItem extends ListItem>(

// If disabled, add to the disabled indexes array
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (!!section.isDisabled || item.isDisabled || item.isDisabledCheckbox) {
if (!!section.isDisabled || (item.isDisabled && !item.isSelected) || item.isDisabledCheckbox) {
disabledOptionsIndexes.push(disabledIndex);
}
disabledIndex += 1;
Expand Down Expand Up @@ -277,7 +277,7 @@ function BaseSelectionList<TItem extends ListItem>(
const selectFocusedOption = () => {
const focusedOption = flattenedSections.allOptions[focusedIndex];

if (!focusedOption || focusedOption.isDisabled) {
if (!focusedOption || (focusedOption.isDisabled && !focusedOption.isSelected)) {
return;
}

Expand Down Expand Up @@ -339,7 +339,7 @@ function BaseSelectionList<TItem extends ListItem>(
const renderItem = ({item, index, section}: SectionListRenderItemInfo<TItem, SectionWithIndexOffset<TItem>>) => {
const normalizedIndex = index + (section?.indexOffset ?? 0);
const isDisabled = !!section.isDisabled || item.isDisabled;
const isItemFocused = !isDisabled && (focusedIndex === normalizedIndex || itemsToHighlight?.has(item.keyForList ?? ''));
const isItemFocused = (!isDisabled || item.isSelected) && (focusedIndex === normalizedIndex || itemsToHighlight?.has(item.keyForList ?? ''));
// We only create tooltips for the first 10 users or so since some reports have hundreds of users, causing performance to degrade.
const showTooltip = shouldShowTooltips && normalizedIndex < 10;

Expand Down

0 comments on commit e1ebfd0

Please sign in to comment.