From 17d95df5d3cf481f9adbdee037e463ca5ca36bf2 Mon Sep 17 00:00:00 2001 From: BeirlaenAaron Date: Fri, 3 Feb 2023 11:23:54 +0100 Subject: [PATCH 1/2] add `preventDefault` on mousedown --- src/components/input/NumericInput.tsx | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/input/NumericInput.tsx b/src/components/input/NumericInput.tsx index c0e9dafc8..35c103898 100644 --- a/src/components/input/NumericInput.tsx +++ b/src/components/input/NumericInput.tsx @@ -1,4 +1,13 @@ -import React, { ChangeEvent, FocusEvent, forwardRef, KeyboardEvent, ReactElement, useEffect, useRef } from 'react'; +import React, { + ChangeEvent, + FocusEvent, + forwardRef, + KeyboardEvent, + MouseEvent, + ReactElement, + useEffect, + useRef, +} from 'react'; import Icon from '../icon'; import { IconAddSmallOutline, @@ -16,7 +25,7 @@ import { GenericComponent } from '../../@types/types'; interface StepperProps { disabled: boolean; onBlur: (event: FocusEvent) => void; - onMouseDown: () => void; + onMouseDown: (event: MouseEvent) => void; onMouseUp: () => void; onMouseLeave: () => void; } @@ -202,7 +211,9 @@ const NumericInput: GenericComponent = forwardRef { + const handleDecreaseMouseDown = (event: MouseEvent) => { + event.preventDefault(); + if (onDecreaseMouseDown) { onDecreaseMouseDown(); @@ -228,7 +239,9 @@ const NumericInput: GenericComponent = forwardRef { + const handleIncreaseMouseDown = (event: MouseEvent) => { + event.preventDefault(); + if (onIncreaseMouseDown) { onIncreaseMouseDown(); From e3e81d98a89bf343e89520b333d78076a26bb605 Mon Sep 17 00:00:00 2001 From: BeirlaenAaron Date: Fri, 3 Feb 2023 11:34:59 +0100 Subject: [PATCH 2/2] bump version + update changelog --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff70e4572..99ecdc245 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,12 @@ ### Dependency updates +## [19.1.1] - 2023-02-03 + +### Fixed + +- `NumericInput`: Fix input blurring when using the stepper buttons ([@BeirlaenAaron](https://github.com/BeirlaenAaron)) in([#2552](https://github.com/teamleadercrm/ui/pull/2552)) + ## [19.1.0] - 2023-02-01 ### Added diff --git a/package.json b/package.json index 129a751c6..5852a29fb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@teamleader/ui", "description": "Teamleader UI library", - "version": "19.1.0", + "version": "19.1.1", "author": "Teamleader ", "bugs": { "url": "https://github.com/teamleadercrm/ui/issues"