Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: onUncombineFeatures and onCombineFeatures is not a function in `direct_select´ draw mode #1175

Open
johanrd opened this issue May 24, 2023 · 0 comments · May be fixed by #1198
Labels

Comments

@johanrd
Copy link
Contributor

johanrd commented May 24, 2023

  1. Go here: https://jsfiddle.net/u6z2a5s4/
  2. Draw a polygon
  3. Enter direct_select mode by clicking on the polygon twice.
  4. Click the combine_features or uncombine_features button, and experience that there are errors in the console:
Screen Shot 2023-05-24 at 06 25 32
object_to_mode.js:61 Uncaught TypeError: i.onCombineFeatures is not a function
    at Object.combineFeatures (object_to_mode.js:61:14)

combineFeatures() {
mode.onCombineFeatures(state);
},
uncombineFeatures() {
mode.onUncombineFeatures(state);
},

I would expect the behavior of the buttons to be similar to in simple_select mode when having selected only one polygon: No effect, yet without uncaught type errors.

probably the safest is to solve by checking for the function before calling it:

combineFeatures() { 
-  mode.onCombineFeatures(state); 
+ if (mode.onCombineFeatures instanceof Function ) {
+    mode.onCombineFeatures(state); 
+ }
 }, 
 uncombineFeatures() { 
-  mode.onUncombineFeatures(state);
+ if (mode.onUncombineFeatures instanceof Function ) {
+    mode.onUncombineFeatures(state); 
+  }
 }

Further, I would also have expected such a TypeError to be detected at compilation time, since both onCombineFeature and onUncombineFeature are well defined as optional in the DrawCustomMode interface

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants