Skip to content

Offset can be incorrect #2849

Description

@tomgreenfield

Subject of the issue

$(selector).offset() can return incorrect values; the variable below always evaluates to a truthy since all elements have html as an ancestor:

const isCorrectedContainer = $element.parents().add($element).filter('html,body,#app').length;

This should be amended to:

const isCorrectedContainer = $element.is('html', 'body', '#app') ||
  $element.parents().is('#app');

Steps to reproduce

  1. Set "_scrollingContainer": { "_isEnabled": true } in the config JSON
  2. Run $('.nav').offset() in the console

Expected behaviour

$('.nav').offset()
{top: 0, left: 0}

Actual behaviour

$('.nav').offset()
{top: -56, left: 0}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions