Skip to content
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

[CP Staging] fix: Category - Unable to select disabled category with keyboard. #41933

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading