Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All Form input fields should implement forwardRef and give us access to internal input element. #5564

Closed
1 task done
Chris3y opened this issue Oct 19, 2022 · 2 comments · Fixed by #5726
Closed
1 task done

Comments

@Chris3y
Copy link

Chris3y commented Oct 19, 2022

Desired behaviour

This would be very convenient for legitimate cases where one must interact with the DOM directly, such as focusing or selecting text in a form input (also important for Sage 200, due to third party integration requirements).

Before switching to function components, this was loosely supported. Class components will always return something to a ref so we could use that the then find the DOM input (see sandbox). It would be nice if all input elements were forwarded refs as a matter of course.

From React docs:

When to Use Refs

There are a few good use cases for refs:

Managing focus, text selection, or media playback.
Triggering imperative animations.
Integrating with third-party DOM libraries.

Current behaviour

Currently, there's no implementation of forwardRef in the components so any ref passed will always be undefined.

Suggested Solution

wrap every form input in forwardRef and pass the ref down to the form input.

CodeSandbox or Storybook URL

https://codesandbox.io/s/can-can-focus-on-old-versions-9rn9mb?file=/src/index.js

Anything else we should know?

Here's a different sandbox, showing what I'm trying to do. Other sandbox contains example of how we used to achieve this when things were class based (using the findDomNode escape hatch which is now discouraged).
https://codesandbox.io/s/kind-browser-ps90bb?file=/src/index.js

Confidentiality

  • I confirm there is no confidential or commercially sensitive information included.
@Chris3y Chris3y added Enhancement triage Triage Required labels Oct 19, 2022
@Parsium
Copy link
Contributor

Parsium commented Oct 25, 2022

FE-5505

@Parsium Parsium added On Backlog and removed triage Triage Required labels Oct 25, 2022
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
the `inputRef` prop is not required on RadioButton as the component uses `React.forwardRef` to pass
a `ref` down to the underlying element

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
These new props allow React refs (callback or object) to be provided to access the underlying DOM
elements of both date inputs if needed.

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
…prop

allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
add new props `dayRef`, `monthRef` and `yearRef` to pass a React ref (object or function) to any of
the inputs making up the component

re #5564
@robinzigmond robinzigmond mentioned this issue Jan 4, 2023
14 tasks
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
add new props `dayRef`, `monthRef` and `yearRef` to pass a React ref (object or function) to any of
the inputs making up the component

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 4, 2023
add new props `dayRef`, `monthRef` and `yearRef` to pass a React ref (object or function) to any of
the inputs making up the component

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
the `inputRef` prop is not required on RadioButton as the component uses `React.forwardRef` to pass
a `ref` down to the underlying element

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
These new props allow React refs (callback or object) to be provided to access the underlying DOM
elements of both date inputs if needed.

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
…prop

allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 18, 2023
add new props `dayRef`, `monthRef` and `yearRef` to pass a React ref (object or function) to any of
the inputs making up the component

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
the `inputRef` prop is not required on RadioButton as the component uses `React.forwardRef` to pass
a `ref` down to the underlying element

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
These new props allow React refs (callback or object) to be provided to access the underlying DOM
elements of both date inputs if needed.

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
…prop

allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
allow a `ref` to be passed directly to the component, removing the need for the `inputRef` prop
which is now deprecated

re #5564
robinzigmond added a commit that referenced this issue Jan 30, 2023
add new props `dayRef`, `monthRef` and `yearRef` to pass a React ref (object or function) to any of
the inputs making up the component

re #5564
carbonci pushed a commit that referenced this issue Feb 3, 2023
## [114.8.0](v114.7.1...v114.8.0) (2023-02-03)

### Features

* **checkbox:** use React.forwardRef and deprecate inputRef prop ([9817fe6](9817fe6)), closes [#5564](#5564)
* **date-range:** add startRef and endRef props ([656662e](656662e)), closes [#5564](#5564)
* **date:** use React.forwardRef and deprecate inputRef prop ([fdaf540](fdaf540)), closes [#5564](#5564)
* **decimal:** useReact.forwardRef and deprecate inputRef prop ([d1876d3](d1876d3)), closes [#5564](#5564)
* **grouped-character:** use React.forwardRef and deprecate inputRef prop ([3737d54](3737d54)), closes [#5564](#5564)
* **number:** use React.forwardRef and deprecate inputRef prop ([8d0215d](8d0215d)), closes [#5564](#5564)
* **numeral-date:** add props to give refs to each input ([df20e7d](df20e7d)), closes [#5564](#5564)
* **radio-button:** deprecate inputRef prop ([171daa7](171daa7)), closes [#5564](#5564)
* **search:** use React.forwardRef and deprecate inputRef prop ([832c44d](832c44d)), closes [#5564](#5564)
* **select:** deprecate inputRef prop ([708cd10](708cd10))
* **switch:** use React.forwardRef and deprecate inputRef prop ([e2f2945](e2f2945)), closes [#5564](#5564)
* **textarea:** use React.forwardRef and deprecate inputRef prop ([afce55f](afce55f)), closes [#5564](#5564)
* **textbox:** use React.forwardRef and deprecate inputRef prop ([17c9e2e](17c9e2e)), closes [#5564](#5564)
* **tile-select:** use React.forwardRef and deprecate inputRef prop ([774aa1a](774aa1a)), closes [#5564](#5564)

### Bug Fixes

* remove internal use of inputRef prop in components ([3745ade](3745ade))
@carbonci
Copy link
Collaborator

carbonci commented Feb 3, 2023

🎉 This issue has been resolved in version 114.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants