Skip to content

LeafletEditor.remove() crashes if no edits were made #888

Open

Description

@JeroenDeDauw

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()`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions