-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix: list even/odd off-by-one issue #25358
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
Conversation
Fixes an issue in List's scrolling example where even and odd were calculated differently in CSS and Javascript. JS was using a 0 index while CSS was using a 1 index so height calculations were off by the height of an element in the List. This was only apparent in lists were items had different heights as in the example.
📊 Bundle size report🤖 This report was generated against 07141711530bbdba82fd5198fe4bcef462403f40 |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 58d77b7:
|
Asset size changesSize Auditor did not detect a change in bundle size for any component! Baseline commit: 07141711530bbdba82fd5198fe4bcef462403f40 (build) |
* master: (106 commits) fix: PopoverTriggerChildProps should be exported (microsoft#25159) feat: replace ToolbarRadio implementation by usage of toggle button as Radio (microsoft#25343) docs: improve Toolbar docs examples (microsoft#25269) feat(tools): add unstable API setup updates (microsoft#25355) applying package updates Fix wrong narration when legend selected (microsoft#24903) applying package updates chore(react-persona): Update beachball settings and change file's type (microsoft#25363) chore: Refactor Field VR tests to have individual tests per component (microsoft#25263) chore(react-persona, react-components, vr-tests-v9): Reverting react-persona's version to beta (microsoft#25357) Publishing migration package (microsoft#25354) fix: Detailslist is still tabbable when isHeaderVisible=false (microsoft#25342) fix: list even/odd off-by-one issue (microsoft#25358) feat: add Dropdown a11y spec (microsoft#24917) spinbutton: update internal padding for small size (microsoft#25286) chore(global-context): migrate to new package structure (microsoft#25341) feat: Add validationState to Progress, to make the bar red or green (microsoft#25253) feat: Add accessibility scenarios for Fluent UI v9 components #3 (microsoft#23334) feat(Dropdown): Freeform search should be case insensitive (microsoft#24879) feat(what-input): Limit keyboard detection in inputs (microsoft#25087) ...
Fixes an issue in List's scrolling example where even and odd were calculated differently in CSS and Javascript. JS was using a 0 index while CSS was using a 1 index so height calculations were off by the height of an element in the List. This was only apparent in lists were items had different heights as in the example.
Current Behavior
List's scrolling example computes even/odd in two different ways which results in even/odd height calculations being mismatched.The first method of computing even/odd is via
nth-child(odd)andnth-child(even)in CSS which is a 1-based syntax.The second method of even/odd computation in in Javascript via the tried-and-true
i % 2 === 0which is a 0-based syntax.This mismatch means that JS thinks the first element in the list is even while CSS thinks it is odd. Because the even rows in the example have different heights than the odd ones this means the computations for scrolling items into view are "off-by-one".
New Behavior
Removes the
nth-childselectors for even and odd, replacing them with classes.evenand.odd. These class are computed in Javascript when rendering the list cell, ensuring we use the same number base for all even/odd computations in the example.Swaps the values of
evenItemHeightandoddItemHeightto maintain the visual appearance of the example.Related Issue(s)
Fixes #23765