Skip to content

Commit

Permalink
Components: fix ToggleGroupControlBackdrop not updating size when `…
Browse files Browse the repository at this point in the history
…isAdaptiveWidth` prop changes (#34595)
  • Loading branch information
ciampo authored Sep 7, 2021
1 parent bd41d50 commit 491eb8a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- Fixed RTL styles in `Flex` component ([#33729](https://github.com/WordPress/gutenberg/pull/33729)).
- Fixed unit test errors caused by `CSS.supports` being called in a non-browser environment ([#34572](https://github.com/WordPress/gutenberg/pull/34572)).
- Fixed `ToggleGroupControl`'s backdrop not updating when changing the `isAdaptiveWidth` property ([#34595](https://github.com/WordPress/gutenberg/pull/34595)).

### Internal

Expand Down
9 changes: 5 additions & 4 deletions packages/components/src/toggle-group-control/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import {
useContextSystem,
WordPressComponentProps,
} from '../ui/context';
import { useUpdateEffect, useCx } from '../utils/hooks';
import { View } from '../view';
import BaseControl from '../base-control';
import * as styles from './styles';
import { useUpdateEffect, useCx } from '../utils/hooks';
import Backdrop from './toggle-group-control-backdrop';
import ToggleGroupControlBackdrop from './toggle-group-control-backdrop';
import type { ToggleGroupControlProps } from './types';
import ToggleGroupControlContext from './toggle-group-control-context';
import * as styles from './styles';

const noop = () => {};

Expand Down Expand Up @@ -101,10 +101,11 @@ function ToggleGroupControl(
ref={ useMergeRefs( [ containerRef, forwardedRef ] ) }
>
{ resizeListener }
<Backdrop
<ToggleGroupControlBackdrop
{ ...radio }
containerRef={ containerRef }
containerWidth={ sizes.width }
isAdaptiveWidth={ isAdaptiveWidth }
/>
{ children }
</RadioGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { BackdropView } from './styles';
function ToggleGroupControlBackdrop( {
containerRef,
containerWidth,
isAdaptiveWidth,
state,
}: ToggleGroupControlBackdropProps ) {
const [ left, setLeft ] = useState( 0 );
Expand Down Expand Up @@ -43,7 +44,7 @@ function ToggleGroupControlBackdrop( {
setCanAnimate( true );
} );
}
}, [ canAnimate, containerRef, containerWidth, state ] );
}, [ canAnimate, containerRef, containerWidth, state, isAdaptiveWidth ] );

return (
<BackdropView
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/toggle-group-control/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ export type ToggleGroupControlButtonProps = {
export type ToggleGroupControlBackdropProps = {
containerRef: MutableRefObject< HTMLElement | undefined >;
containerWidth?: number | null;
isAdaptiveWidth?: boolean;
state?: any;
};

0 comments on commit 491eb8a

Please sign in to comment.