-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
FormTokenField: Deprecate bottom margin #63491
Changes from all commits
3fb59fd
26af576
4090f08
c26edf7
43e4ec5
24449a4
4c0107b
b912e8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ export const Default: StoryFn< typeof FormTokenField > = DefaultTemplate.bind( | |
Default.args = { | ||
label: 'Type a continent', | ||
suggestions: continents, | ||
__nextHasNoMarginBottom: true, | ||
}; | ||
|
||
export const Async: StoryFn< typeof FormTokenField > = ( { | ||
|
@@ -99,6 +100,7 @@ export const Async: StoryFn< typeof FormTokenField > = ( { | |
Async.args = { | ||
label: 'Type a continent', | ||
suggestions: continents, | ||
__nextHasNoMarginBottom: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed that all stories inherit args from either of the 2 definitions that define |
||
}; | ||
|
||
export const DropdownSelector: StoryFn< typeof FormTokenField > = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import { __, _x, sprintf } from '@wordpress/i18n'; | |
import { useEffect, useMemo, useState } from '@wordpress/element'; | ||
import { FormTokenField, withFilters } from '@wordpress/components'; | ||
import { useSelect, useDispatch } from '@wordpress/data'; | ||
import deprecated from '@wordpress/deprecated'; | ||
import { store as coreStore } from '@wordpress/core-data'; | ||
import { useDebounce } from '@wordpress/compose'; | ||
import { speak } from '@wordpress/a11y'; | ||
|
@@ -55,16 +56,28 @@ const termNamesToIds = ( names, terms ) => { | |
/** | ||
* Renders a flat term selector component. | ||
* | ||
* @param {Object} props The component props. | ||
* @param {string} props.slug The slug of the taxonomy. | ||
* @param {Object} props The component props. | ||
* @param {string} props.slug The slug of the taxonomy. | ||
* @param {boolean} props.__nextHasNoMarginBottom Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 7.0. (The prop can be safely removed once this happens.) | ||
* | ||
* @return {JSX.Element} The rendered flat term selector component. | ||
*/ | ||
export function FlatTermSelector( { slug } ) { | ||
export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) { | ||
const [ values, setValues ] = useState( [] ); | ||
const [ search, setSearch ] = useState( '' ); | ||
const debouncedSearch = useDebounce( setSearch, 500 ); | ||
|
||
if ( ! __nextHasNoMarginBottom ) { | ||
deprecated( | ||
'Bottom margin styles for wp.editor.PostTaxonomiesFlatTermSelector', | ||
{ | ||
since: '6.7', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this going to land in 6.7 actually? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, too late to land in 6.6. |
||
version: '7.0', | ||
hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.', | ||
} | ||
); | ||
} | ||
|
||
const { | ||
terms, | ||
termIds, | ||
|
@@ -290,6 +303,7 @@ export function FlatTermSelector( { slug } ) { | |
removed: termRemovedLabel, | ||
remove: removeTermLabel, | ||
} } | ||
__nextHasNoMarginBottom={ __nextHasNoMarginBottom } | ||
/> | ||
<MostUsedTerms taxonomy={ taxonomy } onSelect={ appendTerm } /> | ||
</> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ | |
} | ||
} | ||
|
||
p:not(.components-base-control__help) { | ||
p:not(.components-base-control__help, .components-form-token-field__help) { | ||
margin-top: 0; | ||
} | ||
Comment on lines
+36
to
38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're still rendering the original classname for backward compatibility, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I added a code comment b912e8b