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

Function decrement

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

Source from the content-addressed store, hash-verified

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
178 // input value should be updated to match
179 // ex type 4, press increment, highlight the number in the input, type 4 again, press increment
180 // you'd be at 5, then incrementing to 5 again, so no re-render would happen and 4 would be left in the input
181 if (newValue === colorValue) {
182 setInputValue(newValue.toString('hex'));
183 }
184 safelySetColorValue(newValue);
185 validation.commitValidation();
186 };
187 let incrementToMax = () => safelySetColorValue(MAX_COLOR);
188 let decrementToMin = () => safelySetColorValue(MIN_COLOR);
189

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