Skip to content

Commit

Permalink
Merge pull request #1427 from vtex/fix/quantity-selector-in-touch-scr…
Browse files Browse the repository at this point in the history
…eens

Fix: `NumericStepper` click event
  • Loading branch information
eduardoformiga authored Sep 2, 2022
2 parents f7b2f1e + 5188bed commit 1a2b795
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- **NumericStepper** not working after switching from touch devices.

## [9.146.1] - 2022-03-14

### Removed
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"vendor": "vtex",
"name": "styleguide",
"title": "VTEX Styleguide",
"version": "9.146.1",
"version": "9.146.2",
"description": "The VTEX Styleguide components for the Render framework",
"builders": {
"react": "3.x"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vtex/styleguide",
"version": "9.146.1",
"version": "9.146.2",
"scripts": {
"lint": "eslint react --ext js,jsx,ts,tsx",
"test": "node config/test.js",
Expand Down
15 changes: 4 additions & 11 deletions react/components/NumericStepper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,13 @@ class NumericStepper extends Component {
}

handleIncreaseValue = event => {
event.stopPropagation()
this.changeValue(this.state.value + 1, event, false)
event.preventDefault()
}

handleDecreaseValue = event => {
event.stopPropagation()
this.changeValue(this.state.value - 1, event, false)
event.preventDefault()
}

handleFocusInput = e => {
Expand Down Expand Up @@ -283,11 +283,6 @@ class NumericStepper extends Component {
lean ? 'outline-0' : ''
} `

const touchDevice =
'ontouchstart' in window ||
(typeof navigator !== 'undefined' &&
(navigator?.maxTouchPoints || navigator?.msMaxTouchPoints))

const content = (
<React.Fragment>
{label && (
Expand Down Expand Up @@ -328,8 +323,7 @@ class NumericStepper extends Component {
disabled={readOnly || isMax}
aria-label="+"
tabIndex={0}
onClick={touchDevice ? undefined : this.handleIncreaseValue}
onTouchEnd={touchDevice ? this.handleIncreaseValue : undefined}>
onClick={this.handleIncreaseValue}>
<div className="vtex-numeric-stepper__plus-button__text numeric-stepper__plus-button__text b">
{/* fullwidth plus sign (U+FF0B) http://graphemica.com/%EF%BC%8B */}
Expand All @@ -354,8 +348,7 @@ class NumericStepper extends Component {
// which is the default keyboard character.
// Used for screen readers.
tabIndex={0}
onClick={touchDevice ? undefined : this.handleDecreaseValue}
onTouchEnd={touchDevice ? this.handleDecreaseValue : undefined}>
onClick={this.handleDecreaseValue}>
<span className="vtex-numeric-stepper__minus-button__text numeric-stepper__minus-button__text b">
{/* fullwidth hyphen-minus (U+FF0D) http://graphemica.com/%EF%BC%8D */}
Expand Down

1 comment on commit 1a2b795

@vercel
Copy link

@vercel vercel bot commented on 1a2b795 Sep 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.