Skip to content

Adder position incorrect on page with positioned, centered body. #487

@robertknight

Description

@robertknight

Steps to reproduce

  1. Activate Hypothesis on this page: http://zork.net/~st/jottings/sais.html
  2. Select some text

Expected behaviour

Adder should appear near selection.

Actual behaviour

Adder appears far to right of selection.

Additional details

This page has a narrow body which is centered using margin-left: auto; margin-right: auto;, additionally it is positioned using position: relative.

The Adder (<hypothesis-adder>)'s position is calculated based on the required offset from the left edge of the document, but is set using left: Xpx; position: absolute; which usually works because the positioned ancestor (which X is relative to) is the document element itself. In this case however the positioned ancestor is the <body> and so the end offset is <body>.left + X which results in the adder being shifted to the right because the <body> itself is centered in the page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions