[react-aria-components] Weird behavior on NumberField
buttons
#6980
Unanswered
Manuel-Manoury
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Maybe the 'slot' prop isn't making it through? Otherwise, issues with context being lost are commonly indicative of multiple copies of our packages or accidentally loading two different types of modules from our packages, cjs + mjs or something along those lines. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi 👋
I'm using
react-aria-components
as a base on which I develop my company's design system, and I'm currently scratching my head while usingNumberField
.Everything works fine if I follow the documented usage, i.e. if I use
Button
fromreact-aria-component
directly as a children ofNumberField
.However, I have implemented a custom
Button
as a part of my design system (based onButton
fromreact-aria-component
), which is fairly simple :However, when I use this button, I lose some "automatic behavior" (such as setting the relevant button as disabled when the field value is equal to
minValue
/maxValue
🤔As a result, I tried to create an intermediate component to rely on
useContext(NumberFieldStateContext);
to flag my buttons as disabled when needed, but by doing so I lose another "automatic behavior", namely the binding of theonPress
handlers. They are available through the context mentioned before so it's ok, but I don't understand why those behavior can get "lost" depending on the fact that I add an abstraction layer or not 🤔I tried removing the abstraction (my custom button as a direct child of
NumberField
) and addingforwardRef
anduseContextProps(props, ref, ButtonContext)
along withuseButton(props, ref)
to myButton
abstraction, without changes.I feel like I'm missing something to understand how this work, can you help me figure out what I'm missing here ? Thanks 🙏
Beta Was this translation helpful? Give feedback.
All reactions