-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update some React 18 related types (#45279)
* IsolatedEventContainer: ensure there is type for children * FormFileUpload: fix render() call because void is not assignable to undefined * ToggleControl: enhance help prop type to allow functions * Popover: add types to arrowRef * useFocusOutside: use param type annotation closer to the actual function * useDialog: specify type for event listener, use DOM KeyboardEvent type * ToggleControl fix: show dynamic help label only for controlled components * FormFileUpload: fix the render prop type and behavior * ToggleControl: add changelog entry and update docs
- Loading branch information
Showing
12 changed files
with
109 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/components/src/isolated-event-container/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters