fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

A DetailsList or ShimmeredDetailsList inside a ScrollablePane has unnecessary horizontal scrolling bar

Open sealightPT opened this issue 7 years ago • 24 comments

Bug Report

  • Office-ui-fabric-react 6.162.1
  • Google Chrome Version 73.0.3683.86
  • Windows 10 version 1809

Priorities and help requested

Are you willing to submit a PR to fix? No Requested priority: High Products/sites affected:

Describe the issue:

A DetailsList or ShimmeredDetailsList inside a ScrollablePane has unnecessary horizontal scrolling bar.

Actual behavior:

The horizontal scrollbar is always present, even in unnecessary. image

Expected behavior:

The horizonal scrollbar should only be visibile if there is content to scroll.

Repro:

The official example can be used to reproduce the issue: https://github.com/OfficeDev/office-ui-fabric-react/blob/master/packages/office-ui-fabric-react/src/components/ScrollablePane/examples/ScrollablePane.DetailsList.Example.tsx

Reduce the number of columns (e.g. to 3) to have no reason to scroll.

this._columns = [];
for (let i = 1; i < 4; i++) {
    this._columns.push({
    ...

sealightPT avatar Apr 03 '19 14:04 sealightPT

PS: In some conditions this scss hack works: .ms-DetailsList { > div[role=grid] { max-width: 100px; } }

sealightPT avatar Apr 03 '19 14:04 sealightPT

@KevinTCoughlin @aditima as the code owner and author of DetailsList, could you take a look at this? Thanks!

kkjeer avatar Apr 04 '19 20:04 kkjeer

Regarding the original issue report, I don't see it quite as pronounced in Chrome Version 73.0.3683.86

image

I do see the unnecessary flash of horizontal scrollbar as reported in #7772.

@sealightPT, can you offer any assistance on how to get it to repro as you captured above? Meanwhile, I'll take another pass at resolving the flash of horizontal scroll I am able to repro.


Edit: It looks like there's a stale calculation on inner row elements that causes the outermost DIV container to overflow-x: scroll.

On initial load, the .ms-DetailsList > div[role=grid] box looks like:

image

Then, once the width is modified like what is suggested in https://github.com/OfficeDev/office-ui-fabric-react/issues/8589#issuecomment-479525697, the component re-calculates its width to the precise measurement as to not overflow-x: scroll:

image

KevinTCoughlin avatar Apr 04 '19 22:04 KevinTCoughlin

@KevinTCoughlin, from a blank CRA app we can reproduce the behaviour you mentioned on Chrome: The horizontal scrollbar is visible for a second and then it is hidden However on Edge (Microsoft Edge 44.17763.1.0; Microsoft EdgeHTML 18.17763) the scrollbar is never hidden.

Steps:

npx create-react-app my-app
cd my-app
npm install office-ui-fabric-react
npm install --save typescript @types/node @types/react @types/react-dom @types/jest

Add ScrollablePane.DetailsList.Example.tsx to the project

I then had to comment the following lines for it to compile:

{/* <TextField className={classNames.filter} label="Filter by name:" onChange={this._onFilterChange} /> */}

//   onRenderDetailsHeader={onRenderDetailsHeader}
//   onRenderDetailsFooter={onRenderDetailsFooter}

/*
function onRenderDetailsHeader (...)
function onRenderDetailsFooter (...)
*/

Reduce the number of columns to less than 4:

this._columns = [];
for (let i = 1; i < 4; i++) {

Add the component to your App.js

class App extends Component {
  render() {
    return (
      <div className="App">
        <ScrollablePaneDetailsListExample />
      </div>
    );
  }
}

Then this happens: image

sealightPT avatar Apr 05 '19 14:04 sealightPT

@sealightPT, yea I agree that it happens in the default case. From my prior debug sessions it looks to be a stale width measurement as part of the component's lifecycle. I'm still in search of a fix.

I'd really like to fix this. Its a nasty UI bug.

KevinTCoughlin avatar Apr 08 '19 19:04 KevinTCoughlin

I am seeing the horizontal scroll bar flash still. Is there a good workaround for this?

rachitpuri95 avatar Jul 20 '20 23:07 rachitpuri95

constrainMode={ConstrainMode.unconstrained} -- to detailsList is workaround for this

bharath3719 avatar May 27 '21 06:05 bharath3719

Update: Investigated and think a small change in viewport will fix the issue, prepping a PR.

  • The DetailsList uses getDerivedStateFromProps which calculates the column widths based on the viewport props. getDerivedStateFromProps runs just before each render.
  • The Viewport calculation is based on the scroll rectangle so is calculated based on the contained control (the DetailsList) rendered size.
  • The Viewport calculates initially from componentDidMount.
  • The Viewport resizeObserver is debounced (500ms) both to avoid too many render calls as the user resizes the browser window, but also so the calculation will be based on the contained controls actual size.

Because the DetailsList calculates before rendering and the Viewport depends on the DetailsList rendering, everyone is one step behind. The viewport gets the initial calculation wrong, causing DetailsList to calculate wrong and then render too wide. The viewport then recalculates based on the rendered DetailsList and gets the correct calculation. The DetailsList then recalculates and gets the right column widths and re-renders. Yikes!

The likely fix is to introduce a delay of the initial viewport calculation of the same amount as the delay in the debounced resize observer. From what I see, this causes the viewport to get the initial calculation correct and the DetailsList to not have to recalculate.

GeoffCoxMSFT avatar Sep 13 '21 16:09 GeoffCoxMSFT

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as [email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @fluentui/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @uifabric/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot

:tada:This issue was addressed in #19813, which has now been successfully released as @fluentui/[email protected].:tada:

Handy links:

msft-fluent-ui-bot avatar Sep 16 '21 12:09 msft-fluent-ui-bot