{
+ setAttributes( {
+ placeOrderButtonLabel: content,
+ } );
+ } }
+ />
);
diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx
index e13b0bfd1a6..2f914800272 100644
--- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx
+++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-footer-block/edit.tsx
@@ -3,8 +3,8 @@
*/
import { __ } from '@wordpress/i18n';
import { TotalsItem } from '@woocommerce/blocks-checkout';
-import Button from '@woocommerce/base-components/button';
-import { useBlockProps, RichText } from '@wordpress/block-editor';
+import EditableButton from '@woocommerce/editor-components/editable-button';
+import { useBlockProps } from '@wordpress/block-editor';
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
import {
usePaymentMethods,
@@ -64,35 +64,27 @@ export const Edit = ( {
) }
/>
-
-
+ value={ cartButtonLabel }
+ placeholder={ defaultCartButtonLabel }
+ onChange={ ( content ) => {
+ setAttributes( {
+ cartButtonLabel: content,
+ } );
+ } }
+ />
+ {
+ setAttributes( {
+ checkoutButtonLabel: content,
+ } );
+ } }
+ />
diff --git a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx
index 492e106f7b7..1126e73ec10 100644
--- a/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx
+++ b/assets/js/blocks/mini-cart/mini-cart-contents/inner-blocks/mini-cart-shopping-button-block/edit.tsx
@@ -1,8 +1,8 @@
/**
* External dependencies
*/
-import { useBlockProps, RichText } from '@wordpress/block-editor';
-import Button from '@woocommerce/base-components/button';
+import { useBlockProps } from '@wordpress/block-editor';
+import EditableButton from '@woocommerce/editor-components/editable-button';
/**
* Internal dependencies
@@ -23,21 +23,16 @@ export const Edit = ( {
return (
-
-
-
+
{
+ setAttributes( {
+ startShoppingButtonLabel: content,
+ } );
+ } }
+ />
);
};
diff --git a/assets/js/editor-components/editable-button/index.tsx b/assets/js/editor-components/editable-button/index.tsx
new file mode 100644
index 00000000000..6e012672cac
--- /dev/null
+++ b/assets/js/editor-components/editable-button/index.tsx
@@ -0,0 +1,88 @@
+/**
+ * External dependencies
+ */
+import { useEffect, useRef } from '@wordpress/element';
+import Button, { ButtonProps } from '@woocommerce/base-components/button';
+import { RichText } from '@wordpress/block-editor';
+import type { RefObject } from 'react';
+
+export interface EditableButtonProps
+ extends Omit< ButtonProps, 'onChange' | 'placeholder' | 'value' > {
+ /**
+ * On change callback.
+ */
+ onChange: ( value: string ) => void;
+ /**
+ * The placeholder of the editable button.
+ */
+ placeholder?: string;
+ /**
+ * The current value of the editable button.
+ */
+ value: string;
+}
+
+const EditableButton = ( {
+ onChange,
+ placeholder,
+ value,
+ ...props
+}: EditableButtonProps ) => {
+ const button: RefObject< HTMLButtonElement > = useRef( null );
+
+ // Fix a bug in Firefox that didn't allow to type spaces in editable buttons.
+ // @see https://github.com/woocommerce/woocommerce-blocks/issues/8734
+ useEffect( () => {
+ const buttonEl = button?.current;
+
+ if ( ! buttonEl ) {
+ return;
+ }
+
+ const onKeyDown = ( event: KeyboardEvent ) => {
+ // If the user typed something different than space, do nothing.
+ if ( event.code !== 'Space' ) {
+ return;
+ }
+ event.preventDefault();
+ const selection = buttonEl.ownerDocument.getSelection();
+ if ( selection && selection.rangeCount > 0 ) {
+ // Get the caret position and insert a space.
+ const range = selection.getRangeAt( 0 );
+ range.deleteContents();
+ const textNode = document.createTextNode( ' ' );
+ range.insertNode( textNode );
+ // Set the caret position after the space.
+ range.setStartAfter( textNode );
+ range.setEndAfter( textNode );
+ selection.removeAllRanges();
+ selection.addRange( range );
+ }
+ };
+
+ buttonEl.addEventListener( 'keydown', onKeyDown );
+
+ return () => {
+ if ( ! buttonEl ) {
+ return;
+ }
+ buttonEl.removeEventListener( 'keydown', onKeyDown );
+ };
+ }, [ onChange, value ] );
+
+ return (
+
+ );
+};
+
+export default EditableButton;