Skip to content

Commit

Permalink
fix(react-card): code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosmoura committed Oct 25, 2022
1 parent 0217976 commit d96c04a
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ const focusMap = {
'tab-only': 'unlimited',
} as const;

const useCardFocusAttributes = ({ focusMode = 'off' }: CardProps, isInteractive: boolean) => {
type UseCardFocusAttributesOptions = {
isInteractive: boolean;
};

const useCardFocusAttributes = ({ focusMode = 'off' }: CardProps, { isInteractive }: UseCardFocusAttributesOptions) => {
const internalFocusMode = isInteractive ? 'no-tab' : focusMode;

const groupperAttrs = useFocusableGroup({
tabBehavior: focusMap[internalFocusMode],
});

if (internalFocusMode === 'off') {
return {};
return null;
}

return {
Expand Down Expand Up @@ -60,7 +64,7 @@ export const useCard_unstable = (props: CardProps, ref: React.Ref<CardRefElement
props.onTouchEnd,
);

const focusAttributes = useCardFocusAttributes(props, isInteractive);
const focusAttributes = useCardFocusAttributes(props, { isInteractive });

return {
appearance,
Expand Down

0 comments on commit d96c04a

Please sign in to comment.