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

Block Library: Button: Remove title attribute handling #19735

Merged
merged 2 commits into from
Feb 3, 2020
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
14 changes: 3 additions & 11 deletions packages/block-library/src/button/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import classnames from 'classnames';
import { escape } from 'lodash';

/**
* WordPress dependencies
Expand Down Expand Up @@ -86,7 +85,6 @@ function BorderPanel( { borderRadius = '', setAttributes } ) {
function URLPicker( {
isSelected,
url,
title,
setAttributes,
opensInNewTab,
onToggleOpenInNewTab,
Expand All @@ -102,16 +100,12 @@ function URLPicker( {
>
<LinkControl
className="wp-block-navigation-link__inline-link-input"
value={ { url, title, opensInNewTab } }
value={ { url, opensInNewTab } }
onChange={ ( {
title: newTitle = '',
url: newURL = '',
opensInNewTab: newOpensInNewTab,
} ) => {
setAttributes( {
title: escape( newTitle ),
url: newURL,
} );
setAttributes( { url: newURL } );

if ( opensInNewTab !== newOpensInNewTab ) {
onToggleOpenInNewTab( newOpensInNewTab );
Expand Down Expand Up @@ -164,7 +158,6 @@ function ButtonEdit( {
placeholder,
rel,
text,
title,
url,
} = attributes;
const onSetLinkRel = useCallback(
Expand Down Expand Up @@ -199,7 +192,7 @@ function ButtonEdit( {
} = __experimentalUseGradient();

return (
<div className={ className } title={ title }>
<div className={ className }>
<RichText
placeholder={ placeholder || __( 'Add text…' ) }
value={ text }
Expand All @@ -225,7 +218,6 @@ function ButtonEdit( {
} }
/>
<URLPicker
title={ title }
url={ url }
setAttributes={ setAttributes }
isSelected={ isSelected }
Expand Down
4 changes: 4 additions & 0 deletions packages/block-library/src/button/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export default function save( { attributes } ) {
borderRadius: borderRadius ? borderRadius + 'px' : undefined,
};

// The use of a `title` attribute here is soft-deprecated, but still applied
// if it had already been assigned, for the sake of backward-compatibility.
// A title will no longer be assigned for new or updated button block links.

return (
<div>
<RichText.Content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Buttons can jump to the link editor using the keyboard shortcut 1`] = `
"<!-- wp:buttons -->
<div class=\\"wp-block-buttons\\"><!-- wp:button -->
<div class=\\"wp-block-button\\"><a class=\\"wp-block-button__link\\" href=\\"https://www.wordpress.org/\\" title=\\"\\">WordPress</a></div>
<div class=\\"wp-block-button\\"><a class=\\"wp-block-button__link\\" href=\\"https://www.wordpress.org/\\">WordPress</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->"
`;
Expand Down