Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove shift-stepping from range in RangeControl #35020

Merged
merged 2 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

## Unreleased

### Breaking changes
### Breaking Changes

- Removed the deprecated `position` and `menuLabel` from the `DropdownMenu` component ([#34537](https://github.com/WordPress/gutenberg/pull/34537)).
- Removed the deprecated `onClickOutside` prop from the `Popover` component ([#34537](https://github.com/WordPress/gutenberg/pull/34537)).
- Changed `RangeControl` component to not apply `shiftStep` to inputs from its `<input type="range"/>` ([35020](https://github.com/WordPress/gutenberg/pull/35020)).

### Bug Fix

- Fixed rounding of value in `RangeControl` component when it loses focus while the `SHIFT` key is held. ([#35020](https://github.com/WordPress/gutenberg/pull/35020)).

### Internal

- Deleted the `createComponent` utility function ([#34929](https://github.com/WordPress/gutenberg/pull/34929)).

## 17.0.0 (2021-09-09)

Expand All @@ -22,7 +31,6 @@
### Internal

- Renamed `PolymorphicComponent*` types to `WordPressComponent*` ([#34330](https://github.com/WordPress/gutenberg/pull/34330)).
- Deleted the `createComponent` utility function ([#34929](https://github.com/WordPress/gutenberg/pull/34929)).

## 16.0.0 (2021-08-23)

Expand Down
12 changes: 9 additions & 3 deletions packages/components/src/range-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,12 @@ If no value exists this prop contains the slider starting position.
- Required: No
- Platform: Web | Mobile

### isShiftStepEnabled
#### isShiftStepEnabled

If true, pressing `UP` or `DOWN` along with the `SHIFT` key will increment the value by the `shiftStep` value.
Passed as a prop to the `NumberControl` component and is only applicable if `withInputField` is true. If true, while the number input has focus, pressing `UP` or `DOWN` along with the `SHIFT` key will change the value by the `shiftStep` value.

- Type: `Boolean`
- Required: No
- Default: `true`

#### marks

Expand Down Expand Up @@ -287,6 +286,13 @@ The stepping interval between `min` and `max` values. Step is used both for user
- Required: No
- Platform: Web

#### shiftStep

Passed as a prop to the `NumberControl` component and is only applicable if `withInputField` and `isShiftStepEnabled` are both true and while the number input has focus. Acts as a multiplier of `step`.

- Type: `Number`
- Required: No

#### trackColor

Customizes the (background) color of the track element.
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/range-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ function RangeControl(
describedBy={ describedBy }
disabled={ disabled }
id={ id }
isShiftStepEnabled={ isShiftStepEnabled }
label={ label }
max={ max }
min={ min }
Expand All @@ -227,7 +226,6 @@ function RangeControl(
onMouseMove={ onMouseMove }
onMouseLeave={ onMouseLeave }
ref={ setRef }
shiftStep={ shiftStep }
step={ step }
value={ inputSliderValue }
/>
Expand Down
17 changes: 0 additions & 17 deletions packages/components/src/range-control/input-range.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,20 @@ import { forwardRef } from '@wordpress/element';
*/
import { InputRange as BaseInputRange } from './styles/range-control-styles';
import { useDebouncedHoverInteraction } from './utils';
import { useJumpStep } from '../utils/hooks';

function InputRange(
{
describedBy,
isShiftStepEnabled = true,
label,
onHideTooltip = noop,
onMouseLeave = noop,
step = 1,
onBlur = noop,
onChange = noop,
onFocus = noop,
onMouseMove = noop,
onShowTooltip = noop,
shiftStep = 10,
value,
...props
},
ref
) {
const jumpStep = useJumpStep( {
step,
shiftStep,
isShiftStepEnabled,
} );

const hoverInteractions = useDebouncedHoverInteraction( {
onHide: onHideTooltip,
onMouseLeave,
Expand All @@ -55,11 +42,7 @@ function InputRange(
aria-describedby={ describedBy }
aria-label={ label }
aria-hidden={ false }
onBlur={ onBlur }
onChange={ onChange }
onFocus={ onFocus }
ref={ ref }
step={ jumpStep }
tabIndex={ 0 }
type="range"
value={ value }
Expand Down