Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f
- Added `ariaLabelledBy` props to `Navigation` component to allow a hidden label for accessibility ([#4343](https://github.com/Shopify/polaris-react/pull/4343))
- Add `lastColumnSticky` prop to `IndexTable` to create a sticky last cell and optional sticky last heading on viewports larger than small ([#4150](https://github.com/Shopify/polaris-react/pull/4150))
- Allow promoted actions to be rendered as a menu on the `BulkAction` component ([#4266](https://github.com/Shopify/polaris-react/pull/4266))
- Added `attributes` to the mutation observer for `Popover > PositionedOverlay` “overlay” element ([#4372](https://github.com/Shopify/polaris-react/pull/4372))

### Bug fixes

Expand Down
13 changes: 10 additions & 3 deletions src/components/PositionedOverlay/PositionedOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,14 @@ interface State {
lockPosition: boolean;
}

const OBSERVER_CONFIG = {
export const OBSERVER_CONFIG_OVERLAY = {
childList: true,
subtree: true,
attributes: true,
characterData: true,
};

export const OBSERVER_CONFIG_ACTIVATOR = {
childList: true,
subtree: true,
characterData: true,
Expand Down Expand Up @@ -281,8 +288,8 @@ export class PositionedOverlay extends PureComponent<
},
() => {
if (!this.overlay) return;
this.observer.observe(this.overlay, OBSERVER_CONFIG);
this.observer.observe(activator, OBSERVER_CONFIG);
this.observer.observe(this.overlay, OBSERVER_CONFIG_OVERLAY);
this.observer.observe(activator, OBSERVER_CONFIG_ACTIVATOR);
},
);
},
Expand Down
29 changes: 22 additions & 7 deletions src/components/PositionedOverlay/tests/PositionedOverlay.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import React from 'react';
import {mountWithAppProvider} from 'test-utilities/legacy';

import {EventListener} from '../../EventListener';
import {PositionedOverlay} from '../PositionedOverlay';
import {
PositionedOverlay,
OBSERVER_CONFIG_OVERLAY,
OBSERVER_CONFIG_ACTIVATOR,
} from '../PositionedOverlay';
import * as mathModule from '../utilities/math';
import * as geometry from '../../../utilities/geometry';
import styles from '../PositionedOverlay.scss';
Expand Down Expand Up @@ -38,7 +42,19 @@ describe('<PositionedOverlay />', () => {
mutationObserverObserveSpy.mockRestore();
});

it('observers the activator', () => {
it('observes the overlay', () => {
const positionedOverlay = mountWithAppProvider(
<PositionedOverlay {...mockProps} />,
);
const element = positionedOverlay.find('div').getDOMNode();

expect(mutationObserverObserveSpy).toHaveBeenCalledWith(
element,
OBSERVER_CONFIG_OVERLAY,
);
});

it('observes the activator', () => {
const activator = document.createElement('button');
mountWithAppProvider(
<PositionedOverlay
Expand All @@ -48,11 +64,10 @@ describe('<PositionedOverlay />', () => {
/>,
);

expect(mutationObserverObserveSpy).toHaveBeenCalledWith(activator, {
characterData: true,
childList: true,
subtree: true,
});
expect(mutationObserverObserveSpy).toHaveBeenCalledWith(
activator,
OBSERVER_CONFIG_ACTIVATOR,
);
});
});

Expand Down