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
[Docs]: Document that Overflow
components need to be wrapped around components that forward ref
#27652
Comments
Overflow
components need to be wrapped around components that forward ref
@flora8984461, this happens because the component that // customized component
const ItemVisible = React.forwardRef((props, ref) => {
const isVisible = useIsOverflowItemVisible(props.id);
console.log("Item is visible", isVisible);
return <Button ref={ref}>Item {props.id}</Button>;
});
export const Default = () => {
const styles = useStyles();
const itemIds = new Array(8).fill(0).map((_, i) => i.toString());
return (
<Overflow>
<div className={mergeClasses(styles.container, styles.resizableArea)}>
{itemIds.map((i) => (
<OverflowItem key={i} id={i}>
<ItemVisible id={i} /> // customized component
</OverflowItem>
))}
<OverflowMenu itemIds={itemIds} />
</div>
</Overflow>
);
}; https://codesandbox.io/s/funny-davinci-c29hbm?file=/example.tsx |
Keeping this issue open as a documentation issue |
@ling1726 thank you! The part makes OverflowItem needs ref being forwarded is it here? The ref is being used to render child element? |
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
Because this issue has not had activity for over 150 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
I spent a half hour trying to get Overflow components work. Finally found this crucial information. Please add it to the docs. |
Library
React Components / v9 (@fluentui/react-components)
System Info
Are you reporting Accessibility issue?
None
Reproduction
https://codesandbox.io/s/wandering-morning-to0rl6?file=/example.tsx:2082-2106
Bug Description
Actual Behavior
I am trying to make customized component that is being wrapped by
OverflowItem
.The code looks like:
Because I want to use
useIsOverflowItemVisible
in the customized ItemVisible component to do some extra behavior. However, I got the error in the console:And the overflow does not work,
useIsOverflowItemVisible
always return false even the items are visible.Expected Behavior
I would expect there is no error, and
useIsOverflowItemVisible
can be used and return correct result in customized component that is wrapped inOverflowItem
.Logs
Requested priority
High
Products/sites affected
No response
Are you willing to submit a PR to fix?
yes
Validations
The text was updated successfully, but these errors were encountered: