From c4edcc69e8c5f3df620bfd6a4cfbbf4c2cd43750 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 2 Nov 2026 10:16:25 -0500 Subject: [PATCH 1/2] fix(blocks): render CoreButton links without Link's legacyBehavior Next.js deprecated legacyBehavior and will remove it in a future major, which would break buttons that have a URL. Link now gets the anchor's attributes directly; the rendered markup is unchanged. --- packages/blocks/src/blocks/CoreButton.tsx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/blocks/src/blocks/CoreButton.tsx b/packages/blocks/src/blocks/CoreButton.tsx index 6e36dc23f..f5fcc9ee1 100644 --- a/packages/blocks/src/blocks/CoreButton.tsx +++ b/packages/blocks/src/blocks/CoreButton.tsx @@ -34,14 +34,13 @@ export function CoreButton(props: CoreButtonFragmentProps) { aria-label={attributes?.text} id={attributes?.anchor} className={attributes?.cssClassName}> - - - {attributes?.text} - + + {attributes?.text} ); From 796d9d68d61043e5fbde2af6fd5eae7323748036 Mon Sep 17 00:00:00 2001 From: Joe Fusco Date: Mon, 2 Nov 2026 10:16:46 -0500 Subject: [PATCH 2/2] test(blocks): check CoreButton keeps its link attributes on one anchor --- .../blocks/tests/blocks/CoreButton.test.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/blocks/tests/blocks/CoreButton.test.tsx b/packages/blocks/tests/blocks/CoreButton.test.tsx index 8edbb3565..d12db9c4b 100644 --- a/packages/blocks/tests/blocks/CoreButton.test.tsx +++ b/packages/blocks/tests/blocks/CoreButton.test.tsx @@ -28,6 +28,24 @@ describe('', () => { ); }); + test('puts the link attributes on a single anchor', () => { + const { container } = renderProvider({ + attributes: { + text: 'Click', + url: '/about', + linkClassName: 'wp-block-button__link', + linkTarget: '_blank', + rel: 'noopener', + }, + }); + const link = screen.getByRole('link', { name: 'Click' }); + expect(link).toHaveAttribute('href', '/about'); + expect(link).toHaveAttribute('target', '_blank'); + expect(link).toHaveAttribute('rel', 'noopener'); + expect(link).toHaveClass('wp-block-button__link'); + expect(container.querySelectorAll('a')).toHaveLength(1); + }); + // WordPress 7.0+ stores text alignment in style.typography.textAlign and // adds the has-text-align-* class to the saved markup. test('keeps text alignment from WordPress 7.0+ through the class name', () => {