Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PostExcerpt component to use TextareaControl #4997

Merged
Merged
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
17 changes: 6 additions & 11 deletions editor/components/post-excerpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { ExternalLink, withInstanceId } from '@wordpress/components';
import { ExternalLink, TextareaControl } from '@wordpress/components';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/element';

Expand All @@ -11,17 +11,13 @@ import { compose } from '@wordpress/element';
*/
import './style.scss';

function PostExcerpt( { excerpt, onUpdateExcerpt, instanceId } ) {
const id = `editor-post-excerpt-${ instanceId }`;
const onChange = ( event ) => onUpdateExcerpt( event.target.value );

function PostExcerpt( { excerpt, onUpdateExcerpt } ) {
return (
<div>
<label key="label" htmlFor={ id }>{ __( 'Write an excerpt (optional)' ) }</label>
<textarea
id={ id }
<div className="editor-post-excerpt">
<TextareaControl
label={ __( 'Write an excerpt (optional)' ) }
className="editor-post-excerpt__textarea"
onChange={ onChange }
onChange={ ( value ) => onUpdateExcerpt( value ) }
value={ excerpt }
/>
<ExternalLink href="https://codex.wordpress.org/Excerpt">
Expand All @@ -42,5 +38,4 @@ export default compose( [
dispatch( 'core/editor' ).editPost( { excerpt } );
},
} ) ),
withInstanceId,
] )( PostExcerpt );
4 changes: 4 additions & 0 deletions editor/components/post-excerpt/style.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.editor-post-excerpt > .blocks-base-control {
margin-bottom: 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be specific to EditorPostExcerpt? Seems more like an issue with all TextareaControl that they have too much margin bottom (textarea has its own padding in addition to base control)

}

.editor-post-excerpt__textarea {
width: 100%;
height: 80px;
Expand Down