mapbox / mapbox/mapbox-gl-js

Improve dynamic popup anchoring for tall popups where the bottom can get cut off

Open
#7,675 7 comments 22 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature :green_apple:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

## Motivation

I'm working with a map that includes tooltips which are more than half the height of the map itself. Currently, the top of the popup can never be cut off, which is great. But, when the popup's target location is roughly 2/3 of the way down on the map, the bottom of the popup gets cut off. This jsbin shows an approximation of the problem:

https://jsbin.com/ninahezato/edit?html,output

## Design

Ideally, for the cases where the bottom of the popup was getting cut off, the anchor would switch to 'left' or 'right' (depending on where there was more space), so that the popup's target would be in its vertical center, which would not cut off as much content.

This could probably introduce additional complexities, as in the case where the map is also under a width constraint, so there may be more edge cases to handle.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked JSBin reproduction and trace popup anchor selection in the TypeScript source; the payload names no source file or test. Done means tall popups near the lower map edge choose a side anchor when that preserves more visible content, including the width-constrained edge cases described.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.