Skip to content

feat!: move feature clicks into interactions builders with grouped rows - #1605

Merged
sargunv merged 3 commits into
refactor/step11-layer-buildersfrom
sargunv/rework-feature-click-handling
Dec 6, 2026
Merged

sargunv merged 3 commits into
refactor/step11-layer-buildersfrom
sargunv/rework-feature-click-handling

Conversation

@sargunv

@sargunv sargunv commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Feature clicks only worked on composed layers, each layer took four click parameters (onClick, onLongClick, onDoubleClick, hitPadding) with a ClickEvent receiver, and z-order always won over proximity on overlapping layers.

This PR moves feature and location-puck click handling into interactions { ... } inside the layer builders (building on #2009), introduces ClickHandler and FeatureClickHandler fun interfaces with single event parameters, adds map-wide callbacks.features rows (supporting base-style layers and expanding-padding searches), and adds onUnhandled to doubleClick and longClick.

LineLayer(id = "routes", source = routes) {
  color = const(Color.Blue)
  interactions {
    hitPadding = 12.dp
    onClick { event ->
      select(event.hits.first().feature)
      ClickResult.Consume
    }
  }
}

MapInteractions {
  callbacks {
    features {
      for (padding in listOf(0.dp, 8.dp, 16.dp)) {
        layers("road_motorway", "road_trunk_primary", "road_minor") {
          hitPadding = padding
          onClick { event -> selectStreet(event.hits.first()); ClickResult.Consume }
        }
      }
    }
  }
}

A row's handler runs only when its layers have hits. Hits are grouped front-first, and each layer keeps its query order. Rows run front to back by their topmost layer, with map rows running before a layer's own row when tied.

Migration

  • Replace onClick, onLongClick, onDoubleClick, and hitPadding parameters on Layer, CircleLayer, FillLayer, FillExtrusionLayer, HeatmapLayer, LineLayer, and SymbolLayer with interactions { hitPadding = …; onClick { event -> … } } inside the layer builder.
  • Replace onClick, onLongClick, onDoubleClick, and hitPadding parameters on BasicLocationPuckLayer and material3.LocationPuckLayer with interactions { hitPadding = …; onClick { event -> … } } inside the builder; handlers receive ClickEvent via ClickHandler.
  • Layer handlers take one FeatureClickEvent parameter via FeatureClickHandler instead of a ClickEvent receiver and List<Feature> parameter. Read matched features from event.hits (FeatureHit.layerId, FeatureHit.feature). FeaturesClickHandler is removed.
  • Map-level click, doubleClick, and longClick onEvent/onUnhandled builders now take ClickHandler? (source-compatible for lambda literals).

Closes #1603. Refs #1611.

AI-assisted — Tool: Antigravity; model: google/Gemini 4 Neon

@sargunv

sargunv commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

Note to self: MapInteractions is a value (MapInteractions(from) { … }), while a layer's interactions is a builder lambda. Decide whether these should match, probably alongside the layer-properties builder issue.

@sargunv sargunv added feature Add or change a capability. area:style Styles, sources, layers, images and style-spec properties. area:interaction Input, gestures, callbacks and Compose/Foundation/Material controls. breaking Caller migration or compatibility/support-floor change, whether shipped or unmerged. labels Oct 11, 2026
@sargunv
sargunv force-pushed the sargunv/rework-feature-click-handling branch from e229d66 to 28735ab Compare October 29, 2026 08:41
@sargunv sargunv changed the title feat!: rework feature clicks as grouped interaction rows feat!: move feature clicks into interactions builders with grouped rows Oct 29, 2026
@sargunv
sargunv temporarily deployed to cloudflare-pages October 29, 2026 08:41 — with GitHub Actions Inactive
@blacksmith-sh

This comment has been minimized.

@sargunv
sargunv force-pushed the sargunv/rework-feature-click-handling branch from 28735ab to 515537d Compare October 29, 2026 09:01
@sargunv
sargunv marked this pull request as ready for review October 29, 2026 09:01
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T06:47:02.569928Z 885413a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sargunv
sargunv temporarily deployed to cloudflare-pages October 29, 2026 09:02 — with GitHub Actions Inactive
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no new actionable defects were found.

Summary

Moves feature clicks into interactions builders and adds grouped rows for composed and base-style layers.

  • Map clicks can search named layer groups and deliver their hits in front-first order.
  • Layer and location-puck clicks use interaction blocks instead of separate click parameters.
  • Location, light, and sky settings use explicit callback and builder objects.

AI-assisted — Tool: Greptile; model: OpenAI/gpt-6.1-sol

Diagram

%%{init: {'theme': 'neutral', 'htmlLabels': false}}%%
flowchart TD
  A[Recognized click] --> B[Map onEvent]
  B --> C{Consumed?}
  C -->|Yes| G[Stop]
  C -->|No| D[Query feature rows by layer and padding]
  D --> E[Run rows with hits front to back]
  E --> F{Consumed?}
  F -->|Yes| G
  F -->|No| H[Map onUnhandled]
Loading

Reviews (2) · Last reviewed commit: "feat!: move feature clicks into interact..." · Reviewed by Greptile

@sargunv
sargunv changed the base branch from main to refactor/step11-layer-builders December 6, 2026 06:45
@sargunv
sargunv force-pushed the sargunv/rework-feature-click-handling branch from 515537d to 885413a Compare December 6, 2026 06:45
@sargunv
sargunv added this pull request to stack #2010 December 6, 2026 06:45
@sargunv
sargunv merged commit c2a5a74 into main Dec 6, 2026
16 of 27 checks passed
@sargunv
sargunv deleted the sargunv/rework-feature-click-handling branch December 6, 2026 07:21
@sargunv sargunv mentioned this pull request Dec 6, 2026
49 of 54 tasks

This branch was successfully deployed

1 active deployment
cloudflare-pages — 885413a0 Deployed Dec 6, 2026 by sargunv via docs #5832
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:interaction Input, gestures, callbacks and Compose/Foundation/Material controls. area:style Styles, sources, layers, images and style-spec properties. breaking Caller migration or compatibility/support-floor change, whether shipped or unmerged. feature Add or change a capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move feature click handling into an interactions builder

1 participant