Skip to content

fix: support escaped fields in point selections - #9904

Merged
domoritz merged 1 commit into
vega:mainfrom
vs-li:vl/escaped-fields-point-selection
Aug 24, 2026
Merged

fix: support escaped fields in point selections#9904
domoritz merged 1 commit into
vega:mainfrom
vs-li:vl/escaped-fields-point-selection

Conversation

@vs-li

@vs-li vs-li commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR Description

Summary

Use flatAccessWithDatum when extracting point-selection values.

  • Escaped fields (ex. "field": "y\\[foo\\]") now access datum["y[foo]"].
    • This change applies to point-selection and bound input selections.
  • Existing point-selection behavior remains unchanged for fields without escaped chars.
  • Added regression testing for point tuples and nearest bound selections.

Motivation

Point selections manually generated datum access with stringValue, which quoted escaped field paths without interpreting them:

datum["y\\[foo\\]"]

Other Vega-Lite compiler paths use shared field-access helpers that correctly generate:

datum["y[foo]"]

This caused point-selection behavior to differ from rendering, transforms, predicates, and other generated expressions.
As a result, point selections did not work as expected for marks using escaped field names.

History!

In 2019, #5351 changed selection field access to manual bracket lookup to support flattened fields such as nested.a. This fixed nested selections but bypassed the shared helper that interprets escaped field names.
Escaped bracket support was later added in #5730, but point selections did not inherit the fix when selection types were consolidated in #6927.

2026-07-29-escape-brackets-selection

Checklist

  • This PR is atomic (i.e., it fixes one issue at a time).
  • The title is a concise semantic commit message (e.g. "fix: correctly handle undefined properties").
  • npm test runs successfully
  • For new features:
    • Has unit tests.
    • Has documentation under site/docs/ + examples.

Tips:

@vs-li
vs-li marked this pull request as ready for review July 29, 2026 23:22
@vs-li
vs-li requested a review from a team as a code owner July 29, 2026 23:22
@vs-li

vs-li commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

@domoritz This PR is ready for review as well! Was doing some self-highlight using selection and noticed a bug with escaped fields, so created this.

@domoritz domoritz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thank you!

@domoritz
domoritz merged commit 91eeeb8 into vega:main Aug 24, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants