Skip to content

Commit

Permalink
Card: do not return elevation if its value is undefined when co…
Browse files Browse the repository at this point in the history
…mputing deprecatedProps
  • Loading branch information
ciampo committed Jun 18, 2021
1 parent d5dfd23 commit 6c2cbd9
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/components/src/card/card/hook.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import * as styles from '../styles';
* @param {import('../../ui/context').PolymorphicComponentProps<import('../types').Props, 'div'>} props
*/
function useDeprecatedProps( { elevation, isElevated, ...otherProps } ) {
/**@type {import('../../ui/context').PolymorphicComponentProps<import('../types').Props, 'div'>} */
const propsToReturn = {
...otherProps,
};
let computedElevation = elevation;

if ( isElevated ) {
Expand All @@ -30,10 +34,13 @@ function useDeprecatedProps( { elevation, isElevated, ...otherProps } ) {
computedElevation ??= 2;
}

return {
...otherProps,
elevation: computedElevation,
};
// The `elevation` prop should only be passed when it's not `undefined`,
// otherwise it will override the value that gets derived from `useContextSystem`.
if ( typeof computedElevation !== 'undefined' ) {
propsToReturn.elevation = computedElevation;
}

return propsToReturn;
}

/**
Expand Down

0 comments on commit 6c2cbd9

Please sign in to comment.