From 5360889420914d8a85878cb481499f60a0abfbda Mon Sep 17 00:00:00 2001 From: Ankit Kumar Shah Date: Tue, 7 Jan 2025 11:23:33 +0530 Subject: [PATCH] NumberControl: Disable drag functionality on touch devices --- packages/components/src/number-control/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/components/src/number-control/index.tsx b/packages/components/src/number-control/index.tsx index 6dd1af4024af7f..b8175cdd2de1f7 100644 --- a/packages/components/src/number-control/index.tsx +++ b/packages/components/src/number-control/index.tsx @@ -30,6 +30,10 @@ import { maybeWarnDeprecated36pxSize } from '../utils/deprecated-36px-size'; const noop = () => {}; +const isTouchDevice = () => { + return 'ontouchstart' in window || navigator.maxTouchPoints > 0; +}; + function UnforwardedNumberControl( props: WordPressComponentProps< NumberControlProps, 'input', false >, forwardedRef: ForwardedRef< any > @@ -219,6 +223,8 @@ function UnforwardedNumberControl( }, } ); + const shouldEnableDrag = isDragEnabled && ! isTouchDevice(); + return (