-
Notifications
You must be signed in to change notification settings - Fork 4k
/
index.tsx
32 lines (26 loc) · 958 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
* External dependencies
*/
import type { ComponentPropsWithoutRef, MouseEvent } from 'react';
/**
* WordPress dependencies
*/
import { forwardRef } from '@wordpress/element';
import deprecated from '@wordpress/deprecated';
function stopPropagation( event: MouseEvent ) {
event.stopPropagation();
}
type DivProps = ComponentPropsWithoutRef< 'div' >;
const IsolatedEventContainer = forwardRef< HTMLDivElement, DivProps >(
( props, ref ) => {
deprecated( 'wp.components.IsolatedEventContainer', {
since: '5.7',
} );
// Disable reason: this stops certain events from propagating outside of the component.
// - onMouseDown is disabled as this can cause interactions with other DOM elements.
/* eslint-disable jsx-a11y/no-static-element-interactions */
return <div { ...props } ref={ ref } onMouseDown={ stopPropagation } />;
/* eslint-enable jsx-a11y/no-static-element-interactions */
}
);
export default IsolatedEventContainer;