From 28f0606f54d8e3229d9a07df9c28fd99bef199ae Mon Sep 17 00:00:00 2001
From: Dave Smith
Date: Thu, 4 Sep 2025 09:54:55 +0100
Subject: [PATCH 1/6] refactor: extract shared BackButton component from LinkUI
- Create shared BackButton component to eliminate duplication
- Replace duplicated back button implementations in LinkUIBlockInserter and LinkUIPageCreator
- Standardize back button behavior and styling across components
- Remove unused chevron icon imports from page-creator.js
- Add proper JSDoc documentation for BackButton component
This is the first phase of LinkUI duplication cleanup as discussed in PR #71163 follow-ups.
---
.../src/navigation-link/link-ui.js | 38 ++++++++++++++-----
.../src/navigation-link/page-creator.js | 21 +++++-----
2 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/packages/block-library/src/navigation-link/link-ui.js b/packages/block-library/src/navigation-link/link-ui.js
index eca905d399c34e..efae151339b715 100644
--- a/packages/block-library/src/navigation-link/link-ui.js
+++ b/packages/block-library/src/navigation-link/link-ui.js
@@ -33,6 +33,29 @@ import { useInstanceId, useFocusOnMount } from '@wordpress/compose';
import { unlock } from '../lock-unlock';
import { LinkUIPageCreator } from './page-creator';
+/**
+ * Shared BackButton component for consistent navigation across LinkUI sub-components.
+ *
+ * @param {Object} props Component props.
+ * @param {string} props.className CSS class name for the button.
+ * @param {Function} props.onBack Callback when user wants to go back.
+ */
+function BackButton( { className, onBack } ) {
+ return (
+
+ );
+}
+
const { PrivateQuickInserter: QuickInserter } = unlock(
blockEditorPrivateApis
);
@@ -118,17 +141,10 @@ function LinkUIBlockInserter( { clientId, onBack, onBlockInsert } ) {
-
+ onBack={ onBack }
+ />
-
+ onBack={ onBack }
+ />