Skip to content

fix(ui-date-input,ui-avatar): add ref support to functional components#1938

Merged
matyasf merged 1 commit intomasterfrom
functional_ref_fix
Apr 30, 2025
Merged

fix(ui-date-input,ui-avatar): add ref support to functional components#1938
matyasf merged 1 commit intomasterfrom
functional_ref_fix

Conversation

@matyasf
Copy link
Collaborator

@matyasf matyasf commented Apr 10, 2025

This is needed for things that try to access the ref prop, like our Transition or Position package.
Also we have a page asking users to add the ref prop, see https://instructure.design/#accessing-the-dom
Finally in React 19 this code will be much simpler, see https://react.dev/blog/2024/12/05/react-19#ref-as-a-prop

To test: check is Transition, Position works with Avatar and DateInput2

Fixes INSTUI-4520

@matyasf matyasf self-assigned this Apr 10, 2025
// default to the system's locale
return Locale.browserLocale()
}
const DateInput2 = forwardRef(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual change is just wrapping this in a forwardRef

return (
<TextInput
{...passthroughProps(rest)}
ref={ref}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the only change in the component

@github-actions
Copy link

github-actions bot commented Apr 10, 2025

PR Preview Action v1.6.1
Preview removed because the pull request was closed.
2025-04-30 07:16 UTC

@matyasf matyasf force-pushed the functional_ref_fix branch from 6762739 to 2b414c7 Compare April 22, 2025 21:07
This is needed for things that try to access the ref prop, like our Transition package

INSTUI-4520
@matyasf matyasf force-pushed the functional_ref_fix branch from 2b414c7 to 96807df Compare April 22, 2025 22:02
@matyasf matyasf requested review from HerrTopi and balzss April 23, 2025 13:32
@matyasf matyasf merged commit 6a6ba49 into master Apr 30, 2025
11 checks passed
@matyasf matyasf deleted the functional_ref_fix branch April 30, 2025 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants