Disclosure width issues when placed in Flex #610
-
We're working on the NavigationItem component in the Sidebar and running into some issues with the Disclosure component. If we place the Disclosure component by itself it takes up the full space (as expected): The markup looks like this: const NavigationItem = ({ item }: NavigationItemType) => {
return (
<Disclosure>
<DisclosureHeading
as="div"
variant="heading50"
marginBottom="space0"
style={{ fontWeight: "normal" }}
>
<Flex vAlignContent="center">
<ProductTwilioOrgIcon decorative={true} size="sizeIcon20" />
<Text as="span" paddingLeft="space30">
{item.title}
</Text>
{!item.tags
? null
: item.tags.map((tag) => (
<Text
key={tag}
as="span"
fontStyle="italic"
color="colorTextLink"
paddingLeft="space30"
>
{tag}
</Text>
))}
</Flex>
</DisclosureHeading>
</Disclosure>
);
}; The When I try to place another component next to the (I used chrome dev tools to highlight the size of the parent Code looks like this: const NavigationItem = ({ item }: NavigationItemType) => {
return (
<Flex>
<Disclosure>
<DisclosureHeading
as="div"
variant="heading50"
marginBottom="space0"
style={{ fontWeight: "normal" }}
>
<Flex vAlignContent="center" grow>
<ProductTwilioOrgIcon decorative={true} size="sizeIcon20" />
<Text as="span" paddingLeft="space30">
{item.title}
</Text>
{!item.tags
? null
: item.tags.map((tag) => (
<Text
key={tag}
as="span"
fontStyle="italic"
color="colorTextLink"
paddingLeft="space30"
>
{tag}
</Text>
))}
</Flex>
</DisclosureHeading>
</Disclosure>
</Flex>
);
}; After some investigation it looks like it might be due to the If I use chrome dev tools to set I'm not sure what the best path forward would be, but a couple options might be to allow properties to be set on the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Digging a little deeper and adding The following markup will solve our problem if we could set the width of the underlying const NavigationItem = ({ item, onSetPinnedProduct }: NavigationItemType) => {
return (
<Disclosure>
<Flex>
<Flex grow>
<DisclosureHeading
as="div"
variant="heading50"
marginBottom="space0"
style={{ fontWeight: "normal" }}
>
<Flex vAlignContent="center">
<ProductTwilioOrgIcon decorative={true} size="sizeIcon20" />
<Text as="span" paddingLeft="space30">
{item.title}
</Text>
{!item.tags
? null
: item.tags.map((tag) => (
<Text
key={tag}
as="span"
fontStyle="italic"
color="colorTextLink"
paddingLeft="space30"
>
{tag}
</Text>
))}
</Flex>
</DisclosureHeading>
</Flex>
<NavigationItemDropdown
product={item}
onSetPinnedProduct={onSetPinnedProduct}
/>
</Flex>
<DisclosureContent>
{item.productPages.map((productPage) => (
<NavigationSubItem
productKey={item.key}
subItem={productPage}
key={productPage.key}
/>
))}
</DisclosureContent>
</Disclosure>
);
}; |
Beta Was this translation helpful? Give feedback.
-
Hey @hharnisc - I'm sharing this with the eng team, and we'll followup with you in a bit. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Thanks for reproducing that in the sandbox @hharnisc! Super helpful. Sounds like the recommendation would be to use the Disclosure Primitive in this case—rather than the Disclosure Component—since this use case will require custom styling. I think @SiTaggart can jump in and put together a sandbox showing how that would work. |
Beta Was this translation helpful? Give feedback.
Hey @hharnisc - I'm sharing this with the eng team, and we'll followup with you in a bit. Thanks!