-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coalesce expression doesn't work as expected #5755
Comments
Thanks for the report @muesliq! Could you by any chance provide a live jsfiddle example reproducing this issue? |
This is an outcome of type inference and automatic type assertions. What's happening is that since
Then when the expression is evaluated, it's found that the first This is arguably working as intended, but I think the behavior is so surprising that we will need to revisit the design. |
Nice analysis @jfirebaugh. I think the best fix here is to treat |
mapbox-gl-js version: 0.42.2
Steps to Trigger Behavior
Use this code:
layout: {"text-field": ["coalesce", ["get", "fieldA"], ["get", "fieldB"]]}
where fieldA is null and fieldB is not null
Expected Behavior
Display fieldB.
Actual Behavior
Empty label. (It works though when fieldA is not null, displaying fieldA.)
Note:
A work-around with
case
did the job. However this seems to be a bug. Sorry if I somehow misunderstood the Style Spec and it isn't!The text was updated successfully, but these errors were encountered: