Show global attribute slug without 'pa_' prefix (#41333)

* Show global attribute slug without 'pa_' prefix

* Make implementation more robust
This commit is contained in:
Nathan Silveira 2023-11-13 15:39:58 -03:00 committed by GitHub
parent b24591432d
commit 8d731f8a43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,5 @@
Significance: patch
Type: fix
Comment: Show global attribute slug without 'pa_' prefix

View File

@ -52,6 +52,10 @@ function isNewAttributeListItem( attribute: NarrowedQueryAttribute ): boolean {
return attribute.id === -99;
}
function sanitizeSlugName( slug: string | undefined ): string {
return slug && slug.startsWith( 'pa_' ) ? slug.substring( 3 ) : '';
}
export const AttributeInputField: React.FC< AttributeInputFieldProps > = ( {
value = null,
onChange,
@ -211,7 +215,7 @@ export const AttributeInputField: React.FC< AttributeInputFieldProps > = ( {
tooltipText={
item.isDisabled
? disabledAttributeMessage
: item.slug
: sanitizeSlugName( item.slug )
}
>
{ isNewAttributeListItem( item ) ? (