diff --git a/CHANGELOG.md b/CHANGELOG.md index f45ef7302b6..2284ebad73e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Fixed a bug where default HTML marker positioning was slightly off. [#8074](https://github.com/mapbox/mapbox-gl-js/pull/8074) - Fixed a bug where adding a fill extrusion layer for non-polygon layers would lead to visual artifacts. [#7685](https://github.com/mapbox/mapbox-gl-js/pull/7685) - Fixed intermittent Flow failures on CI. [#8061](https://github.com/mapbox/mapbox-gl-js/pull/8061) +- Fixed a bug where calling `Map#removeFeatureState` does not remove the state from some tile zooms [#8087](https://github.com/mapbox/mapbox-gl-js/pull/8087) ## 0.53.1 diff --git a/src/source/source_state.js b/src/source/source_state.js index 2881432c5a7..0ef77cfce65 100644 --- a/src/source/source_state.js +++ b/src/source/source_state.js @@ -123,8 +123,10 @@ class SourceFeatureState { const layerStates = {}; if (this.deletedStates[sourceLayer] === null) { - for (const ft in this.state[sourceLayer]) layerStates[ft] = {}; - this.state[sourceLayer] = {}; + for (const ft in this.state[sourceLayer]) { + layerStates[ft] = {}; + this.state[sourceLayer][ft] = {}; + } } else { for (const feature in this.deletedStates[sourceLayer]) { const deleteWholeFeatureState = this.deletedStates[sourceLayer][feature] === null; diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#8026/expected.png b/test/integration/render-tests/regressions/mapbox-gl-js#8026/expected.png new file mode 100644 index 00000000000..4cb77303dde Binary files /dev/null and b/test/integration/render-tests/regressions/mapbox-gl-js#8026/expected.png differ diff --git a/test/integration/render-tests/regressions/mapbox-gl-js#8026/style.json b/test/integration/render-tests/regressions/mapbox-gl-js#8026/style.json new file mode 100644 index 00000000000..b5790d49bb6 --- /dev/null +++ b/test/integration/render-tests/regressions/mapbox-gl-js#8026/style.json @@ -0,0 +1,81 @@ +{ + "version": 8, + "metadata": { + "test": { + "width": 64, + "height": 64, + "operations": [ + [ + "setFeatureState", + { + "source": "geojson", + "id": "1" + }, + { + "color": "red" + } + ], + [ + "wait" + ], + [ + "setZoom", 3 + ] + , + [ + "wait" + ], + [ + "removeFeatureState", + { + "source": "geojson" + } + ], + [ + "wait" + ], + [ + "setZoom", 2 + ], + [ + "wait" + ] + ] + } + }, + "zoom": 2, + "sources": { + "geojson": { + "type": "geojson", + "data": { + "type": "Feature", + "id": "1", + "geometry": { + "type": "Point", + "coordinates": [ + 0, + 0 + ] + } + } + } + }, + "layers": [ + { + "id": "circle", + "type": "circle", + "source": "geojson", + "paint": { + "circle-radius": 5, + "circle-color": [ + "coalesce", + [ + "feature-state", + "color" + ], + "black" + ] + } + } + ] +} \ No newline at end of file