@@ -164,18 +164,23 @@ DirectSelect.toDisplayFeatures = function(state, geojson, push) {
164
164
} ;
165
165
166
166
DirectSelect . onTrash = function ( state ) {
167
- // Uses number-aware sorting to make sure '9' < '10'. Comparison is reversed because we want them
168
- // in reverse order so that we can remove by index safely.
169
- state . selectedCoordPaths
170
- . sort ( ( a , b ) => b . localeCompare ( a , 'en' , { numeric : true } ) )
171
- . forEach ( id => state . feature . removeCoordinate ( id ) ) ;
172
- this . fireUpdate ( ) ;
173
- state . selectedCoordPaths = [ ] ;
174
- this . clearSelectedCoordinates ( ) ;
175
- this . fireActionable ( state ) ;
176
- if ( state . feature . isValid ( ) === false ) {
167
+ if ( state . selectedCoordPaths . length === 0 ) {
177
168
this . deleteFeature ( [ state . featureId ] ) ;
178
169
this . changeMode ( Constants . modes . SIMPLE_SELECT , { } ) ;
170
+ } else {
171
+ // Uses number-aware sorting to make sure '9' < '10'. Comparison is reversed because we want them
172
+ // in reverse order so that we can remove by index safely.
173
+ state . selectedCoordPaths
174
+ . sort ( ( a , b ) => b . localeCompare ( a , 'en' , { numeric : true } ) )
175
+ . forEach ( id => state . feature . removeCoordinate ( id ) ) ;
176
+ this . fireUpdate ( ) ;
177
+ state . selectedCoordPaths = [ ] ;
178
+ this . clearSelectedCoordinates ( ) ;
179
+ this . fireActionable ( state ) ;
180
+ if ( state . feature . isValid ( ) === false ) {
181
+ this . deleteFeature ( [ state . featureId ] ) ;
182
+ this . changeMode ( Constants . modes . SIMPLE_SELECT , { } ) ;
183
+ }
179
184
}
180
185
} ;
181
186
0 commit comments