ProfessionalWiki / ProfessionalWiki/Maps

LeafletEditor.remove() crashes if no edits were made

Open Beginner friendly
#888 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
JavaScript
Stars
78
Forks
65
Avg merge
9h 17m
Merged PRs (30d)
6

Description

Issue

`LeafletEditor.remove()` calls `self.saveButton.remove()` unconditionally, but `self.saveButton` is only created when `_showSaveButton()` is called (i.e., after the user creates, edits, or deletes a feature). If `remove()` is called before any edits were made, it crashes with `TypeError: Cannot read properties of undefined (reading 'remove')`.

Steps to reproduce
  1. Initialize the LeafletEditor on a GeoJSON page
  2. Call `editor.remove()` without making any edits
Expected behavior

`remove()` should clean up gracefully regardless of whether edits were made.

Actual behavior

`TypeError: Cannot read properties of undefined (reading 'remove')` — the draw controls and GeoJSON layer are never cleaned up because the error occurs before `self.geoJsonLayer.remove()`.

Contributor guide

No contributing guide indexed for this repository

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 at LeafletEditor.remove() and compare its cleanup sequence with _showSaveButton(), which creates saveButton. Reproduce by initializing the editor and calling remove() before any edits; done means removal completes without a TypeError and the draw controls and GeoJSON layer are cleaned up.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.