-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a forwardRef to wp.blockEditor.PlainText (#14866)
This is a simple change; it allows users of wp.blockEditor.PlainText to pass a reference to the component. A reference may be useful for users, e.g., to manage the focus.
- Loading branch information
1 parent
0fce12a
commit 2b2fc18
Showing
3 changed files
with
17 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { forwardRef } from '@wordpress/element'; | ||
|
||
/** | ||
* External dependencies | ||
*/ | ||
import TextareaAutosize from 'react-autosize-textarea'; | ||
import classnames from 'classnames'; | ||
|
||
function PlainText( { onChange, className, ...props } ) { | ||
const PlainText = forwardRef( ( { onChange, className, ...props }, ref ) => { | ||
return ( | ||
<TextareaAutosize | ||
ref={ ref } | ||
className={ classnames( 'editor-plain-text block-editor-plain-text', className ) } | ||
onChange={ ( event ) => onChange( event.target.value ) } | ||
{ ...props } | ||
/> | ||
); | ||
} | ||
} ); | ||
|
||
export default PlainText; |