From 3e63d6e29b5c9bd7ad22d5a2feacdc49823bb281 Mon Sep 17 00:00:00 2001 From: Jeremy Neal Date: Tue, 9 May 2023 11:55:17 -0400 Subject: [PATCH 1/4] Add back check for groupContext in ActionList Selection component. --- src/ActionList/Selection.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ActionList/Selection.tsx b/src/ActionList/Selection.tsx index 78ed43c2a1c..ae6bb9225a3 100644 --- a/src/ActionList/Selection.tsx +++ b/src/ActionList/Selection.tsx @@ -3,14 +3,18 @@ import {CheckIcon} from '@primer/octicons-react' import {ListContext, ActionListProps} from './List' import {ActionListItemProps} from './shared' import {LeadingVisualContainer} from './Visuals' +import {ActionListGroupProps, GroupContext} from './Group' type SelectionProps = Pick export const Selection: React.FC> = ({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 + let selectionVariant: ActionListProps['selectionVariant'] | ActionListGroupProps['selectionVariant'] + if (typeof groupSelectionVariant !== 'undefined') selectionVariant = groupSelectionVariant + else selectionVariant = listSelectionVariant if (!selectionVariant) { // if selectionVariant is not set on List, but Item is selected From 446102542d96f22d245f84d9328a452745dddf3e Mon Sep 17 00:00:00 2001 From: Jeremy Neal Date: Tue, 9 May 2023 13:19:34 -0400 Subject: [PATCH 2/4] Update src/ActionList/Selection.tsx Co-authored-by: Josh Black --- src/ActionList/Selection.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ActionList/Selection.tsx b/src/ActionList/Selection.tsx index ae6bb9225a3..382601bba1b 100644 --- a/src/ActionList/Selection.tsx +++ b/src/ActionList/Selection.tsx @@ -12,9 +12,7 @@ export const Selection: React.FC> = ({se /** selectionVariant in Group can override the selectionVariant in List root */ /** fallback to selectionVariant from container menu if any (ActionMenu, SelectPanel ) */ - let selectionVariant: ActionListProps['selectionVariant'] | ActionListGroupProps['selectionVariant'] - if (typeof groupSelectionVariant !== 'undefined') selectionVariant = groupSelectionVariant - else selectionVariant = listSelectionVariant + const selectionVariant = groupSelectionVariant ?? listSelectionVariant; if (!selectionVariant) { // if selectionVariant is not set on List, but Item is selected From 9a443e853983ff8b6366b18a7be90af180fbf8a5 Mon Sep 17 00:00:00 2001 From: Josh Black Date: Tue, 9 May 2023 12:49:32 -0500 Subject: [PATCH 3/4] chore: run format --- src/ActionList/Selection.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ActionList/Selection.tsx b/src/ActionList/Selection.tsx index 382601bba1b..ef3cf51887f 100644 --- a/src/ActionList/Selection.tsx +++ b/src/ActionList/Selection.tsx @@ -12,7 +12,7 @@ export const Selection: React.FC> = ({se /** selectionVariant in Group can override the selectionVariant in List root */ /** fallback to selectionVariant from container menu if any (ActionMenu, SelectPanel ) */ - const selectionVariant = groupSelectionVariant ?? listSelectionVariant; + const selectionVariant = groupSelectionVariant ?? listSelectionVariant if (!selectionVariant) { // if selectionVariant is not set on List, but Item is selected From c206a59f637c1f71cf94b07060f69a30bf012dea Mon Sep 17 00:00:00 2001 From: Jeremy Neal Date: Tue, 9 May 2023 14:13:58 -0400 Subject: [PATCH 4/4] Linting. --- src/ActionList/Selection.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ActionList/Selection.tsx b/src/ActionList/Selection.tsx index ef3cf51887f..96ba447b2ef 100644 --- a/src/ActionList/Selection.tsx +++ b/src/ActionList/Selection.tsx @@ -1,9 +1,9 @@ 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 {ActionListGroupProps, GroupContext} from './Group' +import {GroupContext} from './Group' type SelectionProps = Pick export const Selection: React.FC> = ({selected}) => {