File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,9 @@ DirectSelect.clickNoTarget = function () {
9898 this . changeMode ( Constants . modes . SIMPLE_SELECT ) ;
9999} ;
100100
101- DirectSelect . clickInactive = function ( ) {
102- this . changeMode ( Constants . modes . SIMPLE_SELECT ) ;
101+ DirectSelect . clickInactive = function ( state , e ) {
102+ const featureId = e . featureTarget . properties . id ;
103+ this . changeMode ( Constants . modes . SIMPLE_SELECT , { featureIds : [ featureId ] } ) ;
103104} ;
104105
105106DirectSelect . clickActiveFeature = function ( state ) {
@@ -181,11 +182,11 @@ DirectSelect.onTrash = function(state) {
181182
182183DirectSelect . onMouseMove = function ( state , e ) {
183184 // On mousemove that is not a drag, stop vertex movement.
184- const isFeature = isActiveFeature ( e ) ;
185185 const onVertex = isVertex ( e ) ;
186186 const noCoords = state . selectedCoordPaths . length === 0 ;
187- if ( isFeature && noCoords ) this . updateUIClasses ( { mouse : Constants . cursors . MOVE } ) ;
187+ if ( isActiveFeature ( e ) && noCoords ) this . updateUIClasses ( { mouse : Constants . cursors . MOVE } ) ;
188188 else if ( onVertex && ! noCoords ) this . updateUIClasses ( { mouse : Constants . cursors . MOVE } ) ;
189+ else if ( isInactiveFeature ( e ) ) this . updateUIClasses ( { mouse : Constants . cursors . POINTER } ) ;
189190 else this . updateUIClasses ( { mouse : Constants . cursors . NONE } ) ;
190191 this . stopDragging ( state ) ;
191192
Original file line number Diff line number Diff line change @@ -273,6 +273,22 @@ test('direct_select', (t) => {
273273 } ) ;
274274 } ) ;
275275
276+ t . test ( 'direct_select - clicking an inactive feature should select it' , ( st ) => {
277+ const [ lineId ] = Draw . add ( getGeoJSON ( 'line' ) ) ;
278+ const [ polygonId ] = Draw . add ( getGeoJSON ( 'polygon' ) ) ;
279+ Draw . changeMode ( Constants . modes . DIRECT_SELECT , {
280+ featureId : lineId
281+ } ) ;
282+ const clickAt = getGeoJSON ( 'polygon' ) . geometry . coordinates [ 0 ] [ 0 ] ;
283+ afterNextRender ( ( ) => {
284+ click ( map , makeMouseEvent ( clickAt [ 0 ] , clickAt [ 1 ] ) ) ;
285+ afterNextRender ( ( ) => {
286+ t . equal ( Draw . getSelectedIds ( ) . indexOf ( polygonId ) !== - 1 , true , 'polygon is now selected' ) ;
287+ cleanUp ( ( ) => st . end ( ) ) ;
288+ } ) ;
289+ } ) ;
290+ } ) ;
291+
276292 document . body . removeChild ( mapContainer ) ;
277293 t . end ( ) ;
278294} ) ;
You can’t perform that action at this time.
0 commit comments