mapbox / mapbox/mapbox-gl-js

Bug: FeatureState makes id-field not useable when using promoteId

Open
#11,069 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs investigation :mag:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

On init style is correct. But after setting and removing feature-state the style is visible different, but expression is the same.
This only happend by using promoteId and using [id] in style.
For example
this rule works ["==", ["get", "aid" ], 2 ]
this not ["==", ["id"], 2 ]

  • also this happens only by the coresponding feature. For example by clicking on the gray circle, the red one will still be red.
  • it doenst matter if id is set for removeFeatureState
  • looks like its a problem of setFeatureState, because if the feature-rule woudnt fit, it will also change the visible style.
    map.setFeatureState({source: 'points',id: features[0].id,}, {selected: "anyValue"});
  • also other expressions like distance doesnt workt
  • also on text-field this doesnt work anyway, also without using feature-state https://jsfiddle.net/teb7605a/10/

mapbox-gl-js version: 2.5.0

browser: Chrome

Steps to Trigger Behavior
  1. open demo
  2. click on red circle (adds feature-state)
  3. click somewhere else (remove feature-state)
Link to Demonstration

https://jsfiddle.net/o6j1xmkw/1/

Expected Behavior

the selected circle should be red

Actual Behavior

the selected circle is gray.

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 JSFiddle and reproduce the behavior using promoteId, setFeatureState, removeFeatureState, and an [id] expression. Compare the [id] rule with the working get expression and test the reported text-field case. Done means the selected circle remains red after feature-state changes and the corresponding expressions update consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
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.