Skip to content
Merged
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
20 changes: 11 additions & 9 deletions routes/taxonomies/fields.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/**
* WordPress dependencies
*/
import { Notice } from '@wordpress/components';
import { store as coreStore } from '@wordpress/core-data';
import { resolveSelect, useSelect } from '@wordpress/data';
import { useMemo } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import type { Field, Form } from '@wordpress/dataviews';
import { Stack } from '@wordpress/ui';
// eslint-disable-next-line @wordpress/use-recommended-components -- Used here because it supports rendering as a `span` via the `render` prop to avoid invalid HTML.
import { Notice, Stack } from '@wordpress/ui';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm using the Notice component from UI component which while not recommended yet officially, it's fine for the experiment and will keep an eye on it for when is stabilized.


/**
* Internal dependencies
Expand Down Expand Up @@ -114,13 +114,15 @@ export function useSlugField(
type: 'text',
enableGlobalSearch: true,
description: (
<Stack direction="column" gap="sm">
<Stack direction="column" gap="sm" render={ <span /> }>
{ showRenameWarning && (
<Notice status="warning" isDismissible={ false }>
{ __(
'Changing the key renames the taxonomy — existing terms may become inaccessible until a migration updates the database.'
) }
</Notice>
<Notice.Root intent="warning" render={ <span /> }>
<Notice.Description>
{ __(
'Changing the key renames the taxonomy — existing terms may become inaccessible until a migration updates the database.'
) }
</Notice.Description>
</Notice.Root>
) }
<span>
{ __(
Expand All @@ -131,7 +133,7 @@ export function useSlugField(
),
isValid: {
required: true,
pattern: '^[a-z0-9_-]{1,32}$',
pattern: '^[a-z0-9_\\-]{1,32}$',
custom: async ( value: TaxonomyFormData ) => {
const slug = value.slug;
if ( originalSlug !== undefined && slug === originalSlug ) {
Expand Down
Loading