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

NavDrawer is too restrictive about its child element #2773

Closed
myasonik opened this issue Jan 17, 2020 · 2 comments
Closed

NavDrawer is too restrictive about its child element #2773

myasonik opened this issue Jan 17, 2020 · 2 comments

Comments

@myasonik
Copy link
Contributor

Summary

NavDrawer only allows a specific whitelist of children (not sure exactly what it is) primarily: < /> and NavDrawerGroup.

This makes it difficult to break up large navs because you can't wrap parts of it in a component even if that component returns a NavDrawerGroup.

One workaround is to call the component as a function instead of trying to render it as a component. Other than looking hacky and being difficult to debug, I'm not sure if there are any other React-related side effects to doing that.

Pseudo-example

Given a component:

function Group() { return <EuiNavDrawerGroup /> };

This works:

function Nav() {
	return <EuiNavDrawer>{Group()}</EuiNavDrawer>
}

While this does not:

function Nav() {
	return <EuiNavDrawer><Group /></EuiNavDrawer>
}
@chandlerprall
Copy link
Contributor

The best way to better support this functionality will be to have EuiNavDrawer define a React context which gets consumed by EuiNavDrawerGroup. That's all the child-specific logic really cares about - passing two values to the drawer group.

@thompsongl
Copy link
Contributor

Not that I need to tell @myasonik, but EuiCollapsibleNav is the recommended component and we've deprecated EuiNavDrawer.

Closing this as no new features will be considered

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

No branches or pull requests

3 participants