From 5cb5cb8cb2013fb36962a26310554b607bed2bc2 Mon Sep 17 00:00:00 2001 From: Mitchell Austin Date: Tue, 17 May 2022 12:56:20 -0700 Subject: [PATCH 1/2] Remove forced focus of `InputControl` on mousedown --- .../src/input-control/input-field.tsx | 18 ------------------ .../components/src/input-control/test/index.js | 17 ----------------- 2 files changed, 35 deletions(-) diff --git a/packages/components/src/input-control/input-field.tsx b/packages/components/src/input-control/input-field.tsx index d9b5a293a0fa6e..2b731d1c866aca 100644 --- a/packages/components/src/input-control/input-field.tsx +++ b/packages/components/src/input-control/input-field.tsx @@ -9,7 +9,6 @@ import type { PointerEvent, FocusEvent, ForwardedRef, - MouseEvent, } from 'react'; /** @@ -187,22 +186,6 @@ function InputField( ); const dragProps = isDragEnabled ? dragGestureProps() : {}; - /* - * Works around the odd UA (e.g. Firefox) that does not focus inputs of - * type=number when their spinner arrows are pressed. - */ - let handleOnMouseDown; - if ( type === 'number' ) { - handleOnMouseDown = ( event: MouseEvent< HTMLInputElement > ) => { - props.onMouseDown?.( event ); - if ( - event.currentTarget !== - event.currentTarget.ownerDocument.activeElement - ) { - event.currentTarget.focus(); - } - }; - } return ( { } ); } ); - describe( 'Ensurance of focus for number inputs', () => { - it( 'should focus its input on mousedown events', async () => { - const user = await userEvent.setup(); - const spy = jest.fn(); - render( ); - const target = getInput(); - - // Hovers the input and presses (without releasing) primary button. - await user.pointer( [ - { target }, - { keys: '[MouseLeft]', target }, - ] ); - - expect( spy ).toHaveBeenCalledTimes( 1 ); - } ); - } ); - describe( 'Value', () => { it( 'should update value onChange', async () => { const user = await userEvent.setup(); From ba7bea27e81c7aa5c8ae07a2afc8578d3c722184 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Tue, 3 Jun 2025 11:12:12 +0200 Subject: [PATCH 2/2] CHANGELOG --- packages/components/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 4e9ddc5a729127..14cbfeaccc3370 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -16,6 +16,7 @@ - Expose `normalizeTextString` method as private API ([#70178](https://github.com/WordPress/gutenberg/pull/70178)). - Mark `withIgnoreIMEEvents()` function as private API ([#70056](https://github.com/WordPress/gutenberg/pull/70056)). +- `InputControl`: remove unnecessary forced focus on `mousedown` ([#41118](https://github.com/WordPress/gutenberg/pull/41118)). ## 29.10.0 (2025-05-22) @@ -42,7 +43,7 @@ - `ToggleGroupControl`: Fix active background for empty string value ([#69969](https://github.com/WordPress/gutenberg/pull/69969)). - `ItemGroup`: Fix double border in `ItemGroup` when last item is focused ([#70021](https://github.com/WordPress/gutenberg/pull/70021)). - `__experimentalUseCustomUnits `: Don't mutate 'ALL_CSS_UNITS' default value ([#70037](https://github.com/WordPress/gutenberg/pull/70037)). -- `FocalPointPicker`: Fix SVG display when it doesn't provide a width attribute ([#70061](https://github.com/WordPress/gutenberg/pull/70061)).. +- `FocalPointPicker`: Fix SVG display when it doesn't provide a width attribute ([#70061](https://github.com/WordPress/gutenberg/pull/70061)).. ### Internal