mapbox / mapbox/mapbox-gl-draw

activateUIButton("myMode") and deactivate functionality

Open
#1,213 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug
Dominant language
JavaScript
Stars
1.1k
Forks
612
Avg merge
8d 9h
Merged PRs (30d)
5

Description

## User Story

I create my own custom mode as per documentation:

``` typescript
const mapboxDraw = new MapboxDraw({
//...
modes: {
...MapboxDraw.modes,
myMode: MyMode,
},
// PS. Object.assign gives me type error so I spread the existing modes.

```

Then in MyMode.ts

```typescript
MyMode.onSetup = function (opt) {
this.activateUIButton("myMode");
// doesn't work
}

MyMode.onStop = function (state) {
this.activateUIButton();
// deactivates stock Mode buttons (i.e Polygon)
// but when stock Mode is active, does not deactivate myMode.
}
```

- I was able to work the activation by creating a toggle function to add the ".active" class.
- I was unable to work the second issue, if I click a stock Mode, it does not deactivate MyMode button.

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 custom mode example in MyMode.ts and reproduce the activateUIButton("myMode") and deactivation behavior described in the issue. Trace how stock mode buttons are activated and deactivated, then verify that the custom button activates on setup and deactivates when switching modes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.