Skip to content

Commit

Permalink
update comment
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed May 16, 2024
1 parent 742b440 commit d66f315
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ function BaseSelectionList<TItem extends ListItem>(
const incrementPage = () => setCurrentPage((prev) => prev + 1);

/**
* Iterates through the sections and items inside each section, and builds 3 arrays along the way:
* Iterates through the sections and items inside each section, and builds 4 arrays along the way:
* - `allOptions`: Contains all the items in the list, flattened, regardless of section
* - `disabledOptionsIndexes`: Contains the indexes of all the unselectable (isDisabledCheckbox) and disabled items in the list
* - `disabledArrowKeyOptionsIndexes`: Contains the indexes of all the disabled items in the list, to be used by the ArrowKeyFocusManager
* - `disabledOptionsIndexes`: Contains the indexes of all the unselectable and disabled items in the list
* - `disabledArrowKeyOptionsIndexes`: Contains the indexes of item that is not navigatable by the arrow key. The list is separated from disabledOptionsIndexes because unselectable item is still navigatable by the arrow key.
* - `itemLayouts`: Contains the layout information for each item, header and footer in the list,
* so we can calculate the position of any given item when scrolling programmatically
*/
Expand Down Expand Up @@ -132,10 +132,11 @@ function BaseSelectionList<TItem extends ListItem>(
});

// If disabled, add to the disabled indexes array
const isItemDisabled = !!section.isDisabled || (item.isDisabled && !item.isSelected);
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
if (!!section.isDisabled || (item.isDisabled && !item.isSelected) || item.isDisabledCheckbox) {
if (isItemDisabled || item.isDisabledCheckbox) {
disabledOptionsIndexes.push(disabledIndex);
if (!!section.isDisabled || item.isDisabled) {
if (isItemDisabled) {
disabledArrowKeyOptionsIndexes.push(disabledIndex);
}
}
Expand Down

0 comments on commit d66f315

Please sign in to comment.