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

Fix : Duplicative link control label and placeholder #66329

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions packages/block-editor/src/components/link-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ const PREFERENCE_KEY = 'linkControlSettingsDrawer';
* @param {WPLinkControlProps} props Component props.
*/
function LinkControl( {
searchInputLabel,
searchInputPlaceholder,
Vrishabhsk marked this conversation as resolved.
Show resolved Hide resolved
value,
settings = DEFAULT_LINK_SETTINGS,
Expand Down Expand Up @@ -390,6 +391,7 @@ function LinkControl( {
<LinkControlSearchInput
currentLink={ value }
className="block-editor-link-control__field block-editor-link-control__search-input"
label={ searchInputLabel }
placeholder={ searchInputPlaceholder }
value={ currentUrlInputValue }
withCreateSuggestion={ withCreateSuggestion }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const LinkControlSearchInput = forwardRef(
children,
currentLink = {},
className = null,
label = null,
placeholder = null,
withCreateSuggestion = false,
onCreateSuggestion = noop,
Expand Down Expand Up @@ -113,18 +114,16 @@ const LinkControlSearchInput = forwardRef(
}
};

const inputLabel = placeholder ?? __( 'Search or type URL' );

return (
<div className="block-editor-link-control__search-input-container">
<URLInput
disableSuggestions={ currentLink?.url === value }
label={ inputLabel }
label={ label ?? __( 'Search or type URL' ) }
hideLabelFromVision={ hideLabelFromVision }
className={ className }
value={ value }
onChange={ onInputChange }
placeholder={ inputLabel }
Vrishabhsk marked this conversation as resolved.
Show resolved Hide resolved
placeholder={ placeholder ?? __( 'Search' ) }
__experimentalRenderSuggestions={
showSuggestions ? handleRenderSuggestions : null
}
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/specs/editor/blocks/links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ test.describe( 'Links', () => {
// Change the URL.
// getByPlaceholder required in order to handle Link Control component
// managing focus onto other inputs within the control.
await page.getByPlaceholder( 'Search or type URL' ).fill( '' );
await page.getByPlaceholder( 'Search' ).fill( '' );
await page.keyboard.type( '/handbook' );

// Submit the link.
Expand Down Expand Up @@ -349,7 +349,7 @@ test.describe( 'Links', () => {
// Change the URL.
// getByPlaceholder required in order to handle Link Control component
// managing focus onto other inputs within the control.
await page.getByPlaceholder( 'Search or type URL' ).fill( '' );
await page.getByPlaceholder( 'Search' ).fill( '' );
await page.keyboard.type( '/handbook' );

// Submit the link.
Expand Down Expand Up @@ -679,7 +679,7 @@ test.describe( 'Links', () => {
// Change the URL.
// Note: getByPlaceholder required in order to handle Link Control component
// managing focus onto other inputs within the control.
await linkPopover.getByPlaceholder( 'Search or type URL' ).fill( '' );
await linkPopover.getByPlaceholder( 'Search' ).fill( '' );
await page.keyboard.type( 'wordpress.org' );

// Save the link.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ test.describe( 'Registered sources', () => {
.getByRole( 'button', { name: 'Edit link', exact: true } )
.click();
await page
.getByPlaceholder( 'Search or type URL' )
.getByPlaceholder( 'Search' )
.fill( '#url-custom-field-modified' );
await pageUtils.pressKeys( 'Enter' );

Expand Down Expand Up @@ -693,9 +693,7 @@ test.describe( 'Registered sources', () => {
await page
.getByRole( 'button', { name: 'Edit link', exact: true } )
.click();
await page
.getByPlaceholder( 'Search or type URL' )
.fill( testingImgSrc );
await page.getByPlaceholder( 'Search' ).fill( testingImgSrc );
await pageUtils.pressKeys( 'Enter' );

// Check that the image url attribute didn't change and still uses the placeholder.
Expand Down
Loading