Skip to content

Commit

Permalink
Fix/issue 12033 url label (#12959)
Browse files Browse the repository at this point in the history
* merge from upstream

* local save

* darked focus state outline for block lists

* sasve

* updated permalink labelling

* reverted package lock

* updated label and added helper link

* post link text update

* Update index.js
  • Loading branch information
timwright12 authored and gziolo committed Feb 13, 2019
1 parent 9802a0c commit 458b945
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions packages/edit-post/src/components/sidebar/post-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,38 +53,46 @@ function PostLink( {
onToggle={ onTogglePanel }
>
{ isEditable && (
<TextControl
label={ __( 'URL' ) }
value={ forceEmptyField ? '' : currentSlug }
onChange={ ( newValue ) => {
editPermalink( newValue );
// When we delete the field the permalink gets
// reverted to the original value.
// The forceEmptyField logic allows the user to have
// the field temporarily empty while typing.
if ( ! newValue ) {
if ( ! forceEmptyField ) {
<div className="editor-post-link">
<TextControl
label={ __( 'URL Slug' ) }
value={ forceEmptyField ? '' : currentSlug }
onChange={ ( newValue ) => {
editPermalink( newValue );
// When we delete the field the permalink gets
// reverted to the original value.
// The forceEmptyField logic allows the user to have
// the field temporarily empty while typing.
if ( ! newValue ) {
if ( ! forceEmptyField ) {
setState( {
forceEmptyField: true,
} );
}
return;
}
if ( forceEmptyField ) {
setState( {
forceEmptyField: false,
} );
}
} }
onBlur={ ( event ) => {
editPermalink( cleanForSlug( event.target.value ) );
if ( forceEmptyField ) {
setState( {
forceEmptyField: true,
forceEmptyField: false,
} );
}
return;
}
if ( forceEmptyField ) {
setState( {
forceEmptyField: false,
} );
}
} }
onBlur={ ( event ) => {
editPermalink( cleanForSlug( event.target.value ) );
if ( forceEmptyField ) {
setState( {
forceEmptyField: false,
} );
}
} }
/>
} }
/>
<p>
{ __( 'The last part of the URL. ' ) }
<ExternalLink href="https://codex.wordpress.org/Posts_Add_New_Screen">
{ __( 'Read about permalinks' ) }
</ExternalLink>
</p>
</div>
) }
<p className="edit-post-post-link__preview-label">
{ __( 'Preview' ) }
Expand Down

0 comments on commit 458b945

Please sign in to comment.