MCPcopy Index your code
hub / github.com/adobe/react-spectrum / increment

Function increment

packages/react-stately/src/color/useColorFieldState.ts:163–174  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161 };
162
163 let increment = () => {
164 let newValue = addColorValue(parsedValue, step);
165 // if we've arrived at the same value that was previously in the state, the
166 // input value should be updated to match
167 // ex type 4, press increment, highlight the number in the input, type 4 again, press increment
168 // you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
169 if (newValue === colorValue) {
170 setInputValue(newValue.toString('hex'));
171 }
172 safelySetColorValue(newValue);
173 validation.commitValidation();
174 };
175 let decrement = () => {
176 let newValue = addColorValue(parsedValue, -step);
177 // if we've arrived at the same value that was previously in the state, the

Callers 2

useNumberFieldFunction · 0.50
useColorFieldFunction · 0.50

Calls 4

addColorValueFunction · 0.85
safelySetColorValueFunction · 0.85
commitValidationMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected