Skip to content

Commit

Permalink
Extract Wrapper into an external component to avoid rerender, and the…
Browse files Browse the repository at this point in the history
…refore, blur/clearing tag control
  • Loading branch information
ramonjd committed Oct 31, 2024
1 parent beae8ad commit 4603b5c
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ const termNamesToIds = ( names, terms ) => {
.filter( ( id ) => id !== undefined );
};

const Wrapper = ( { children, __nextHasNoMarginBottom } ) =>
__nextHasNoMarginBottom ? (
<VStack spacing={ 4 }>{ children }</VStack>
) : (
<Fragment>{ children }</Fragment>
);

/**
* Renders a flat term selector component.
*
Expand Down Expand Up @@ -292,15 +299,8 @@ export function FlatTermSelector( { slug, __nextHasNoMarginBottom } ) {
singularName
);

const Wrapper = ( { children } ) =>
__nextHasNoMarginBottom ? (
<VStack spacing={ 4 }>{ children }</VStack>
) : (
<Fragment>{ children }</Fragment>
);

return (
<Wrapper>
<Wrapper __nextHasNoMarginBottom={ __nextHasNoMarginBottom }>
<FormTokenField
__next40pxDefaultSize
value={ values }
Expand Down

0 comments on commit 4603b5c

Please sign in to comment.