mapbox / mapbox/mapbox-gl-js

Config expression not evaluated in filter

Open
#13,180 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :lady_beetle:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version**: v3.3.0

**browser**: irrelevant

### Steps to Trigger Behavior

Add config schema to map style
```
"schema": {
"test": {"default": true},
},
```
Using `'filter': ['!', ['config', 'test', 'basemap']]` [config.js#L81 evaluate()](https://github.com/mapbox/mapbox-gl-js/blob/acc665f77fa6852c11c3755f69afcb781c15b7cd/src/style-spec/expression/definitions/config.js#L81) is never called and always returns false, even when the config is set to true.

**_Workaround:_**
config expression inside style properties is evaluated properly (when created with createPropertyExpression )
`'visibility': ['case', ['config', 'test', 'basemap'], 'none', 'visible']`

IMHO the filter has to be updated anyway. Right now we can't use the new expression syntax when using the old deprecated filter keywords like `==` or `in` and so on. Maybe add an _addLayer_ option to make it a data driven expression with new syntax only, which supports config or just completely ditch support for the deprecated syntax.
If you really want to keep support for the old syntax, maybe add an indicator for using the new syntax with
`filter: ['v2', [...]]`

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 src/style-spec/expression/definitions/config.js evaluate() implementation, then trace how filters are parsed and evaluated versus style properties created with createPropertyExpression. Reproduce the schema and filter example from the issue, compare it with the visibility workaround, and establish the expected behavior for config expressions and deprecated filter syntax. Done means the intended filter behavior is defined and covered by regression testing.

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.