Skip to content

Conversation

@spmonahan
Copy link
Contributor

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) and nth-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 === 0 which 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-child selectors for even and odd, replacing them with classes .even and .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 evenItemHeight and oddItemHeight to maintain the visual appearance of the example.

Related Issue(s)

Fixes #23765

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.
@fabricteam
Copy link
Collaborator

📊 Bundle size report

🤖 This report was generated against 07141711530bbdba82fd5198fe4bcef462403f40

@codesandbox-ci
Copy link

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:

Sandbox Source
@fluentui/react 8 starter Configuration
@fluentui/react-components 9 starter Configuration

@size-auditor
Copy link

size-auditor bot commented Oct 24, 2022

Asset size changes

Size Auditor did not detect a change in bundle size for any component!

Baseline commit: 07141711530bbdba82fd5198fe4bcef462403f40 (build)

@spmonahan spmonahan merged commit 9bf103a into microsoft:master Oct 24, 2022
marcosmoura added a commit to marcosmoura/fluentui that referenced this pull request Oct 25, 2022
* 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)
  ...
NotWoods pushed a commit to NotWoods/fluentui that referenced this pull request Nov 18, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: List scrolling does not render the full bottom row

7 participants