react-spectrum icon indicating copy to clipboard operation
react-spectrum copied to clipboard

[RAC] inputRef is undefined in Textfield

Open mehdibha opened this issue 9 months ago • 1 comments

Provide a general summary of the issue here

Textfield is providing an InputContext but when consuming it, the inputRef is undefined I am consuming it like this

const { ref } = useSlottedContext(InputContext)
const Demo = ()=> {
  return (
    <TextField>
      <Input />
      <Btn />
    </TextField>
}

const Btn = () => {
  const inputCtx = useSlottedContext(InputContext)
  return (
    <Button onPress={()=>{console.log(inputCtx?.ref?.current))>Log</Button>
}

🤔 Expected Behavior?

Expecting to ref to return the actual ref of the Ìnput in the TextField component

😯 Current Behavior

Currently the ref is undefined

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

https://codesandbox.io/p/sandbox/rac-textfield-input-ref-issue-d93cvl

Version

1.2

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Windows

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

mehdibha avatar May 19 '24 13:05 mehdibha