Skip to content

Commit

Permalink
Embed Block: Replace native input element with InputControl component (
Browse files Browse the repository at this point in the history
…WordPress#64668)

* Embed Block: Replace native input element with InputControl component

* Don't use hardcoded label

Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
  • Loading branch information
4 people authored and bph committed Aug 31, 2024
1 parent c10cf40 commit b446304
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/embed/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const EmbedEdit = ( props ) => {
} }
value={ url }
cannotEmbed={ cannotEmbed }
onChange={ ( event ) => setURL( event.target.value ) }
onChange={ ( value ) => setURL( value ) }
fallback={ () => fallback( url, onReplace ) }
tryAgain={ () => {
invalidateResolution( 'getEmbedPreview', [ url ] );
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/embed/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
justify-content: center;
}

.wp-block-embed__placeholder-input {
flex: 1 1 auto;
}

// Stops long URLs from breaking out of the no preview available screen
.components-placeholder__error {
word-break: break-word;
Expand Down
11 changes: 7 additions & 4 deletions packages/block-library/src/embed/embed-placeholder.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ExternalLink,
__experimentalHStack as HStack,
__experimentalVStack as VStack,
__experimentalInputControl as InputControl,
} from '@wordpress/components';
import { BlockIcon } from '@wordpress/block-editor';

Expand All @@ -31,15 +32,17 @@ const EmbedPlaceholder = ( {
) }
>
<form onSubmit={ onSubmit }>
<input
<InputControl
__next40pxDefaultSize
type="url"
value={ value || '' }
className="components-placeholder__input"
aria-label={ label }
className="wp-block-embed__placeholder-input"
label={ label }
hideLabelFromVision
placeholder={ __( 'Enter URL to embed here…' ) }
onChange={ onChange }
/>
<Button variant="primary" type="submit">
<Button __next40pxDefaultSize variant="primary" type="submit">
{ _x( 'Embed', 'button label' ) }
</Button>
</form>
Expand Down

0 comments on commit b446304

Please sign in to comment.