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

URLInput: Deprecate bottom margin #46692

Merged
merged 4 commits into from
Jan 4, 2023
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
1 change: 1 addition & 0 deletions packages/block-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

- `URLInput`: the `renderSuggestions` callback prop now receives `currentInputValue` as a new parameter ([45806](https://github.com/WordPress/gutenberg/pull/45806)).
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that URLInput is included in the changelog already. Should I have added my PR below, or is it fine the way I did it?

Copy link
Member

Choose a reason for hiding this comment

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

This way is fine 👍

- Fluid typography: add configurable fluid typography settings for minimum font size to theme.json ([#42489](https://github.com/WordPress/gutenberg/pull/42489)).
- `URLInput`: Add `__nextHasNoMarginBottom` prop for opting into the new margin-free styles ([46692](https://github.com/WordPress/gutenberg/pull/46692)).

### Bug Fix

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const LinkControlSearchInput = forwardRef(
return (
<div className="block-editor-link-control__search-input-container">
<URLInput
__nextHasNoMarginBottom
label={ useLabel ? 'URL' : undefined }
className={ inputClasses }
value={ value }
Expand Down
5 changes: 5 additions & 0 deletions packages/block-editor/src/components/url-input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ When hiding the URLInput using CSS (as is sometimes done for accessibility purpo

This prop allows the suggestions list to be programmatically not rendered by passing a boolean—it can be `true` to make sure suggestions aren't rendered, or `false`/`undefined` to fall back to the default behaviour of showing suggestions when matching autocompletion items are found.

### `__nextHasNoMarginBottom: Boolean`

Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4. (The prop can be safely removed once this happens.)

## Example

{% codetabs %}
Expand Down Expand Up @@ -217,6 +221,7 @@ registerBlockType( /* ... */, {
edit( { className, attributes, setAttributes } ) {
return (
<URLInput
__nextHasNoMarginBottom
className={ className }
value={ attributes.url }
onChange={ ( url, post ) => setAttributes( { url, text: (post && post.title) || 'Click here' } ) }
Expand Down
1 change: 1 addition & 0 deletions packages/block-editor/src/components/url-input/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class URLInputButton extends Component {
onClick={ this.toggle }
/>
<URLInput
__nextHasNoMarginBottom
value={ url || '' }
onChange={ onChange }
/>
Expand Down
16 changes: 15 additions & 1 deletion packages/block-editor/src/components/url-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import scrollIntoView from 'dom-scroll-into-view';
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';
import { __, sprintf, _n } from '@wordpress/i18n';
import { Component, createRef } from '@wordpress/element';
import { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';
Expand Down Expand Up @@ -424,6 +425,8 @@ class URLInput extends Component {

renderControl() {
const {
/** Start opting into the new margin-free styles that will become the default in a future version. */
__nextHasNoMarginBottom = false,
label = null,
className,
isFullWidth,
Expand Down Expand Up @@ -477,8 +480,19 @@ class URLInput extends Component {
return renderControl( controlProps, inputProps, loading );
}

if ( ! __nextHasNoMarginBottom ) {
deprecated( 'Bottom margin styles for wp.blockEditor.URLInput', {
since: '6.2',
version: '6.5',
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',
} );
}

return (
<BaseControl { ...controlProps }>
<BaseControl
__nextHasNoMarginBottom={ __nextHasNoMarginBottom }
{ ...controlProps }
>
<input { ...inputProps } />
{ loading && <Spinner /> }
</BaseControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function LinkEditor( {
{ ...props }
>
<URLInput
__nextHasNoMarginBottom
value={ value }
onChange={ onChangeInputValue }
autocompleteRef={ autocompleteRef }
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const SocialLinkURLPopover = ( {
>
<div className="block-editor-url-input">
<URLInput
__nextHasNoMarginBottom
value={ url }
onChange={ ( nextURL ) =>
setAttributes( { url: nextURL } )
Expand Down