Skip to content

Can't set multiple selected coordinates when switching to Direct Select mode #967

@DannyDelott

Description

@DannyDelott

I'm writing a custom mode that lets a user box select over a Line feature to select multiple vertices, then pass them off to direct_select so they can be moved around or deleted.

This is convenient when the Line feature is a windy road or otherwise contains lots of vertices where shift + clicking each one would be a hassle.

The problem I'm running into is that Direct Select only accepts a single coordPath in onSetup, which means we can only pass a single vertex off to Direct Select mode.

selectedCoordPaths: opts.coordPath ? [opts.coordPath] : []

To make this work, I've forked Direct Select mode and tweaked the above line of code so that the caller is responsible for passing a coordPath array, instead of expecting onSetup to wrap it:

 selectedCoordPaths: opts.coordPath ? opts.coordPath : [] 

This gives me my expected result.

box-select-mapbox

If it makes sense, I'm happy to push up a PR with this small change. Or maybe there's a more idiomatic way to do this that I'm not seeing :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions