-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Provide a general summary of the issue here
When setting signDisplay to "never", <NumberField>'s decrement button converts negative values to positive, resulting in an incorrect post-decrement value
🤔 Expected Behavior?
Negative values should remain negative
😯 Current Behavior
Negative values are converted to positive
💁 Possible Solution
No response
🔦 Context
No response
🖥️ Steps to Reproduce
https://stackblitz.com/edit/vitejs-vite-xxqht6jk?file=src%2FApp.jsx
import { useState } from 'react';
import {
NumberField,
Label,
Group,
Input,
Button,
} from 'react-aria-components';
function App() {
const [showSign, setShowSign] = useState(true);
const [value, setValue] = useState(0);
return (
<>
<div>
<input
id="show-sign"
type="checkbox"
checked={showSign}
onChange={(event) => setShowSign(event.target.checked)}
/>
<label htmlFor="show-sign">Show sign</label>
</div>
<hr />
<NumberField
formatOptions={{ signDisplay: showSign ? 'auto' : 'never' }}
onChange={setValue}
value={value}
>
<Label>Value: {value}</Label>
<Group>
<Button slot="decrement">-</Button>
<Input />
<Button slot="increment">+</Button>
</Group>
</NumberField>
</>
);
}
export default App;To reproduce:
- Set value to
0 - Check 'Show sign'
- Decrement value twice
- Notice that value decrements in the negative direction correctly:
0→-1→-2
- Notice that value decrements in the negative direction correctly:
- Set value to
0 - Uncheck 'Show sign'
- Decrement value twice
- Notice that value is not correctly decremented:
0→-1→0
- Notice that value is not correctly decremented:
Version
What browsers are you seeing the problem on?
Safari
If other, please specify.
No response
What operating system are you using?
macOS Tahoe 26.1
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working