Skip to content

Commit

Permalink
Add back check for GroupContext in ActionList.Selection to fix issues…
Browse files Browse the repository at this point in the history
… introduced to github/github (#3267)

* Add back check for groupContext in ActionList Selection component.

* Update src/ActionList/Selection.tsx

Co-authored-by: Josh Black <joshblack@github.com>

* chore: run format

* Linting.

---------

Co-authored-by: Josh Black <joshblack@github.com>
Co-authored-by: Josh Black <joshblack@users.noreply.github.com>
  • Loading branch information
3 people authored May 9, 2023
1 parent 2417cfe commit 332a1af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/ActionList/Selection.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import React from 'react'
import {CheckIcon} from '@primer/octicons-react'
import {ListContext, ActionListProps} from './List'
import {ListContext} from './List'
import {ActionListItemProps} from './shared'
import {LeadingVisualContainer} from './Visuals'
import {GroupContext} from './Group'

type SelectionProps = Pick<ActionListItemProps, 'selected'>
export const Selection: React.FC<React.PropsWithChildren<SelectionProps>> = ({selected}) => {
const {selectionVariant: groupSelectionVariant} = React.useContext(GroupContext)
const {selectionVariant: listSelectionVariant} = React.useContext(ListContext)

/** selectionVariant in Group can override the selectionVariant in List root */
/** fallback to selectionVariant from container menu if any (ActionMenu, SelectPanel ) */
const selectionVariant: ActionListProps['selectionVariant'] = listSelectionVariant
const selectionVariant = groupSelectionVariant ?? listSelectionVariant

if (!selectionVariant) {
// if selectionVariant is not set on List, but Item is selected
Expand Down

0 comments on commit 332a1af

Please sign in to comment.