Skip to content

Placeholder causes the window to scroll-down when using ui-bootstrap's popoverΒ #34

@omril1

Description

@omril1

Noticed this bug when opening a small popover when the sticky element (table header in my case) was sticky and the placeholder for the sticky element is completely out of view.

Bootstrap's popover causes a re-render of the sticky element, which cause the placeholder to be removed and re-added back, and a window scroll down (by the placeholder/sticky element's height).

Using the event change API we see that the the bootstrap poopover causes a change from stick to stick

<div hl-sticky event="stickyChanged(event)"></div>

function stickyChanged({event)}) {
  console.log(event); //prints stick every time the popover is opened
}

Diagnosed it with chrome dev-tools performance tab (browser render happens right after the sticky state render)
image


For people who get this bug too:

A fix we did was to counteract the scrolling side-effect was to scroll back that amount of pixels inside the event attribute provided with the API of the directive.

Something like:

function stickyChanged({event: stickyStatus}) {
  const scrollDiff = window.scrollY - <PLACEHOLDER_HEIGHT>;

  if (stickyStatus == 'stick' && lastStickyStatus == stickyStatus) {
    if (scrollDiff >= 50) {
      window.scrollBy(0, - <PLACEHOLDER_HEIGHT>); //should be negative in our case
    }
  }
  lastStickyStatus = stickyStatus;
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions