-
Notifications
You must be signed in to change notification settings - Fork 83
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
Forwarding refs to <Input>-component in ffe-form-react #231
Comments
const Input = ({ className, inline, textLike, ...rest }) => {
return (
<input
className={classNames(
'ffe-input-field',
{ 'ffe-input-field--inline': inline },
{ 'ffe-input-field--text-like': textLike },
className,
)}
{...rest} {/* <-- This stuff right here */}
/>
);
}; So if you set a <Input
inline={true}
textLike={true}
ref={_ref => { this._refs.input = _ref; }}
/> |
I thought the |
Oh, I see. Then it would be nice to use the new |
+1 on the |
BREAKING CHANGE: Requires React 16.3.0 and above! This commit lets the consumer pass refs down to the `Input` and `TextArea` components, to handle focus et al. The only breaking change is the fact that React 16.3.0 is required. Fixes #231.
BREAKING CHANGE: Requires React 16.3.0 and above! This commit lets the consumer pass refs down to the `Input` and `TextArea` components, to handle focus et al. The only breaking change is the fact that React 16.3.0 is required. Fixes #231.
BREAKING CHANGE: Requires React 16.4.0 and above! This commit lets the consumer pass refs down to the `Input` and `TextArea` components, to handle focus et al. The only breaking change is the fact that React 16.4.0 is required. This commit also disables two test suites, since Enzyme doesn't yet support React's newest versions. For more information, please refer to this issue: Fixes #231.
So I've fixed this in the PR, but enzyme (our React testing framework) doesn't support the feature yet. I've fixed this temporarily by disabling tests for two components, but I'm not sure if this is good enough for a merge. The fix is merged to master, but not released yet (hasn't been for 3 months). |
BREAKING CHANGE: Requires React 16.4.0 and above! This commit lets the consumer pass refs down to the `Input` and `TextArea` components, to handle focus et al. The only breaking change is the fact that React 16.4.0 is required. This commit also disables two test suites, since Enzyme doesn't yet support React's newest versions. For more information, please refer to this issue: Fixes #231.
Which package is this issue related to: ffe-form-react
Describe your issue (screenshots welcome!)
This is more of a technical feature request. I am working on another internal component at SB1, that adds managed formatting to an input. I want to use the
Input
from ffe-form, but need to access the DOM ref to manage selection/cursor position. I currently achieve this with ReactDOM.findDOMNode().There are two potential ways to improve this:
Give Input a new property
inputRef
, that takes a callback and passes it toref
on the contained .Upgrade to React 16.3.0 and use the new forwardRef API.
If there is consensus on such a change, I could make a PR.
BR, Preben Ludviksen
The text was updated successfully, but these errors were encountered: