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

[EuiForm] pass fullWidth from root EuiForm via context to children #6214

Closed
spalger opened this issue Sep 7, 2022 · 2 comments · Fixed by #6229
Closed

[EuiForm] pass fullWidth from root EuiForm via context to children #6214

spalger opened this issue Sep 7, 2022 · 2 comments · Fixed by #6229

Comments

@spalger
Copy link
Contributor

spalger commented Sep 7, 2022

When writing an <EuiForm> which is supposed to expand to the full width of the container you need to add fullWidth to every form group, row, and input in the form. It would be awesome if we could specify fullWidth on the EuiForm element and have that change the default value of fullWidth within each child component by passing true down via context.

If folks wouldn't mind this being implemented I'd be happy to try putting up a PR.

@cee-chen
Copy link
Contributor

cee-chen commented Sep 7, 2022

We always love getting PRs! What approach are you thinking in terms of implementation? Are you thinking of either a ReactContext set by EuiForm, or using React.cloneElement on each child/grandchild to try to set props?

FWIW I'd lean slightly towards context over cloneElement, and if using a context, I'd also want individual children to be able to set their own fullWidth prop that overrides the context.

Hope that helps!

@spalger
Copy link
Contributor Author

spalger commented Sep 7, 2022

Yeah, I was planning to go with context. I'll give it a shot and make sure that child elements only use the fullWidth from context if their fullWidth prop is undefined.

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

Successfully merging a pull request may close this issue.

2 participants