Skip to content

Commit

Permalink
Remove stateReducer memoization. Add isPressEnterToChange knob for In…
Browse files Browse the repository at this point in the history
…put stories
  • Loading branch information
Jon Q committed May 14, 2020
1 parent db4f125 commit 920060b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/components/src/input-control/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { flattenDeep } from 'lodash';
/**
* WordPress dependencies
*/
import { useMemo, useReducer } from '@wordpress/element';
import { useReducer } from '@wordpress/element';

const initialStateReducer = ( state ) => state;

Expand Down Expand Up @@ -179,13 +179,9 @@ export function useInputControlStateReducer(
initialState = initialInputControlState
) {
const combinedReducers = combineStateReducers( stateReducer );
const reducer = useMemo(
() => inputControlStateReducer( combinedReducers ),
[]
);

const [ state, dispatch ] = useReducer(
reducer,
inputControlStateReducer( combinedReducers ),
mergeInitialState( initialState )
);

Expand Down
1 change: 1 addition & 0 deletions packages/components/src/input-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function Example() {
disabled: boolean( 'disabled', false ),
hideLabelFromVision: boolean( 'hideLabelFromVision', false ),
isFloatingLabel: boolean( 'isFloatingLabel', false ),
isPressEnterToChange: boolean( 'isPressEnterToChange', false ),
label: text( 'label', 'Value' ),
placeholder: text( 'placeholder', 'Placeholder' ),
size: select(
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/number-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function Example() {
disabled: boolean( 'disabled', false ),
hideLabelFromVision: boolean( 'hideLabelFromVision', false ),
isFloatingLabel: boolean( 'isFloatingLabel', false ),
isPressEnterToChange: boolean( 'isPressEnterToChange', false ),
isShiftStepEnabled: boolean( 'isShiftStepEnabled', true ),
label: text( 'label', 'Number' ),
min: number( 'min', 0 ),
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/unit-control/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function Example() {
disableUnits: boolean( 'disableUnits', false ),
hideLabelFromVision: boolean( 'hideLabelFromVision', false ),
isFloatingLabel: boolean( 'isFloatingLabel', false ),
isPressEnterToChange: boolean( 'isPressEnterToChange', true ),
isShiftStepEnabled: boolean( 'isShiftStepEnabled', true ),
isUnitSelectTabbable: boolean( 'isUnitSelectTabbable', true ),
label: text( 'label', 'Value' ),
Expand Down

0 comments on commit 920060b

Please sign in to comment.