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

[Bug]: useIsOverflowItemVisible returns incorrect at initial state #27656

Closed
2 tasks done
flora8984461 opened this issue Apr 21, 2023 · 4 comments · Fixed by #27756
Closed
2 tasks done

[Bug]: useIsOverflowItemVisible returns incorrect at initial state #27656

flora8984461 opened this issue Apr 21, 2023 · 4 comments · Fixed by #27756

Comments

@flora8984461
Copy link
Contributor

Library

React Components / v9 (@fluentui/react-components)

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 Intel(R) Xeon(R) W-2133 CPU @ 3.60GHz
    Memory: 51.85 GB / 63.57 GB
  Browsers:
    Edge: Spartan (44.22621.1105.0), Chromium (109.0.1518.78)
    Internet Explorer: 11.0.22621.1

Are you reporting Accessibility issue?

None

Reproduction

https://codesandbox.io/s/admiring-feather-mtyojz?file=/example.tsx

Bug Description

Actual Behavior

At initial state when there is enough space for all items to show, useIsOverflowItemVisible returns false for each item. As the screenshot shows, and you can also check it in the reproduction codesandbox. It feels like at initial state, and the space is enough, items are not registered to the overflow or the initial context set to false; and the state in context changes only after resize happens. (Let me know if my guess is correct, thank you 😊)

image

Expected Behavior

Expect the useIsOverflowItemVisible returns true when initial state the items are really showing.

Logs

No response

Requested priority

High

Products/sites affected

No response

Are you willing to submit a PR to fix?

yes

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.
@flora8984461
Copy link
Contributor Author

Hi @ling1726 Do you have any timeline for this to be fixed? We are planning on our product's release. Thank you!

@ling1726
Copy link
Member

@flora8984461 I've added this to the next sprint 01/05 - 14/05

ling1726 added a commit to ling1726/fluentui that referenced this issue May 4, 2023
Fixes microsoft#27656 which was caused by a priority queue edge case.

On initial mount the resize observer will always run. If there is
already overflow then the tops of the visibility queues will be
different from the initial state (all items are considered visible by
default).

In the cause where there is no overflow initially the queue tops will
not change, which does not trigger a dispatch to the react bindings so
the `useIsOverflowItemVisible` hook will always return `false` until
overflow occurs.

The fix is quite simple: set the initial value of flag `forceDispatch`
to be `true` which will always trigger a dispatch for initial mount.
ling1726 added a commit that referenced this issue May 9, 2023
* fix: overflowManager should always dispatch initial state

Fixes #27656 which was caused by a priority queue edge case.

On initial mount the resize observer will always run. If there is
already overflow then the tops of the visibility queues will be
different from the initial state (all items are considered visible by
default).

In the cause where there is no overflow initially the queue tops will
not change, which does not trigger a dispatch to the react bindings so
the `useIsOverflowItemVisible` hook will always return `false` until
overflow occurs.

The fix is quite simple: set the initial value of flag `forceDispatch`
to be `true` which will always trigger a dispatch for initial mount.

* changefile
@msft-fluent-ui-bot msft-fluent-ui-bot added Status: Fixed Fixed in some PR and removed Status: In PR labels May 9, 2023
@msft-fluent-ui-bot
Copy link
Collaborator

🎉This issue was addressed in #27756, which has now been successfully released as @fluentui/priority-overflow@v9.0.3.:tada:

Handy links:

@msft-fluent-ui-bot
Copy link
Collaborator

🎉This issue was addressed in #27756, which has now been successfully released as @fluentui/react-overflow@v9.0.16.:tada:

Handy links:

@microsoft microsoft locked as resolved and limited conversation to collaborators Jun 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants