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
34 changes: 17 additions & 17 deletions packages/media-fields/src/attached_to/edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default function MediaAttachedToEdit( {
post: 0,
_embedded: { ...data?._embedded, 'wp:attached-to': undefined },
} );
setValue( null );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rest the state early rather than waiting for a round trip.

setOptions( [] );
};

Expand Down Expand Up @@ -146,23 +147,22 @@ export default function MediaAttachedToEdit( {
}
};

const help = !! data.post
? createInterpolateElement(
__(
'Search for a post or page to attach this media to or <button>detach current</button>.'
),
{
button: (
<Button
__next40pxDefaultSize
onClick={ handleDetach }
variant="link"
accessibleWhenDisabled
/>
),
}
)
: __( 'Search for a post or page to attach this media to.' );
const help = createInterpolateElement(
__(
'Search for a post or page to attach this media to or <button>detach current</button>.'
),
{
button: (
<Button
__next40pxDefaultSize
onClick={ handleDetach }
variant="link"
accessibleWhenDisabled
disabled={ ! value }
/>
),
}
);

return (
<ComboboxControl
Expand Down
Loading