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

ScrollablePane with DetailsList cannot scroll fixed header with list content #5116

Closed
luckyyd opened this Issue Jun 6, 2018 · 3 comments

Comments

Projects
None yet
5 participants
@luckyyd

luckyyd commented Jun 6, 2018

Bug Report

  • Package version(s): 5.106
  • Browser and OS versions: Chrome, Windows 10

Priorities and help requested (not applicable if asking question):

Are you willing to submit a PR to fix? (Yes, No)
No
Requested priority: (Blocking, High, Normal, Low)
High
Products/sites affected: (if applicable)

Describe the issue:

When using DetailsList within Scrollable Pane, if the DetailsList has more columns that exceeds the div width, when scroll below, both column header and detailslist appears both horizontal scroll bar, but cannot scroll together:
Scroll to the top:
image
Scroll down
image

Expected behavior:

The sticky header should scroll with detailslist together.

If applicable, please provide a codepen repro:

Code:
image

@leddie24 leddie24 self-assigned this Jun 6, 2018

@kirankumarmanku

This comment has been minimized.

Show comment
Hide comment
@kirankumarmanku

kirankumarmanku Jun 11, 2018

Hi,
I am also facing the similar issue with DetailsList with ScrollablePane. Is there any temporary workaround for this?

kirankumarmanku commented Jun 11, 2018

Hi,
I am also facing the similar issue with DetailsList with ScrollablePane. Is there any temporary workaround for this?

@kirankumarmanku

This comment has been minimized.

Show comment
Hide comment
@kirankumarmanku

kirankumarmanku Jun 11, 2018

Hi,
Following fix worked for me. I have added onScroll event for the div containing ScrollablePane and attached the following method.

private handleScroll(event) {
  let element = document.querySelector("[class*='stickyAbove-']");
  if(element != null)
      element.scrollLeft = event.target.scrollLeft;
}

I am returning following element.


     <div style={ {
          height: '100%',
          position: 'relative',
          maxHeight: 'inherit'
        } }
          onScroll = {this.handleScroll}
         >
              <ScrollablePane>
                <DetailsList
                  items={ sortedItems as any[] }
                  columns={ columns }
                  compact={false}
                  ariaLabel= "List of data"
                  setKey='items'
                  className = {styles.myclass}
                  layoutMode={ DetailsListLayoutMode.fixedColumns }
                  onRenderDetailsHeader={
                    // tslint:disable-next-line:jsx-no-lambda
                    (detailsHeaderProps: IDetailsHeaderProps, defaultRender: IRenderFunction<IDetailsHeaderProps>) => (
                      <Sticky 
                      stickyPosition={StickyPositionType.Header} >
                        { defaultRender({
                          ...detailsHeaderProps,
                           onRenderColumnHeaderTooltip: (tooltipHostProps: ITooltipHostProps) => <TooltipHost {...tooltipHostProps} />
                        }) }
                      </Sticky>
                    ) }
                  selectionMode={SelectionMode.none}
                  constrainMode = {ConstrainMode.unconstrained}
                  onColumnHeaderClick={ this.onColumnClick }
                />
              </ScrollablePane>
         </div>

kirankumarmanku commented Jun 11, 2018

Hi,
Following fix worked for me. I have added onScroll event for the div containing ScrollablePane and attached the following method.

private handleScroll(event) {
  let element = document.querySelector("[class*='stickyAbove-']");
  if(element != null)
      element.scrollLeft = event.target.scrollLeft;
}

I am returning following element.


     <div style={ {
          height: '100%',
          position: 'relative',
          maxHeight: 'inherit'
        } }
          onScroll = {this.handleScroll}
         >
              <ScrollablePane>
                <DetailsList
                  items={ sortedItems as any[] }
                  columns={ columns }
                  compact={false}
                  ariaLabel= "List of data"
                  setKey='items'
                  className = {styles.myclass}
                  layoutMode={ DetailsListLayoutMode.fixedColumns }
                  onRenderDetailsHeader={
                    // tslint:disable-next-line:jsx-no-lambda
                    (detailsHeaderProps: IDetailsHeaderProps, defaultRender: IRenderFunction<IDetailsHeaderProps>) => (
                      <Sticky 
                      stickyPosition={StickyPositionType.Header} >
                        { defaultRender({
                          ...detailsHeaderProps,
                           onRenderColumnHeaderTooltip: (tooltipHostProps: ITooltipHostProps) => <TooltipHost {...tooltipHostProps} />
                        }) }
                      </Sticky>
                    ) }
                  selectionMode={SelectionMode.none}
                  constrainMode = {ConstrainMode.unconstrained}
                  onColumnHeaderClick={ this.onColumnClick }
                />
              </ScrollablePane>
         </div>
@coreyroth

This comment has been minimized.

Show comment
Hide comment
@coreyroth

coreyroth Oct 3, 2018

I have found that you also need to capture the scroll event on the Sticky as well in case the user scrolls the header. I registered a scroll event with the following:

public componentDidMount(): void { let stickyElemrent = document.querySelector("[class*='stickyAbove-']") if (stickyElemrent != null) { stickyElemrent.addEventListener('scroll', this.hnadleStickyScroll); } }

Then I used a similar event handling method:

private hnadleStickyScroll(event) { let gridElement = document.querySelector("[class*='ms-DetailsList']"); if (gridElement) gridElement.scrollLeft = event.target.scrollLeft; event.preventDefault(); }

I wrote more on it in this post.

coreyroth commented Oct 3, 2018

I have found that you also need to capture the scroll event on the Sticky as well in case the user scrolls the header. I registered a scroll event with the following:

public componentDidMount(): void { let stickyElemrent = document.querySelector("[class*='stickyAbove-']") if (stickyElemrent != null) { stickyElemrent.addEventListener('scroll', this.hnadleStickyScroll); } }

Then I used a similar event handling method:

private hnadleStickyScroll(event) { let gridElement = document.querySelector("[class*='ms-DetailsList']"); if (gridElement) gridElement.scrollLeft = event.target.scrollLeft; event.preventDefault(); }

I wrote more on it in this post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment