Skip to content

Commit

Permalink
Map: Add location field to ClickEvent type & pass event to onClick
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Farkhutdinov committed Feb 20, 2025
1 parent 7a3bd87 commit 498699b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ const AzureProvider = DynamicProvider.inherit({

_clickActionHandler(e) {
if (e.type === 'click') {
this._fireClickAction({ location: this._normalizeLocation(e.position) });
this._fireClickAction({
location: this._normalizeLocation(e.position),
event: e.originalEvent,
});
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const GoogleProvider = DynamicProvider.inherit({
},

_clickActionHandler(e) {
this._fireClickAction({ location: this._normalizeLocation(e.latLng) });
this._fireClickAction({ location: this._normalizeLocation(e.latLng), event: e.domEvent });
},

updateDimensions() {
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/js/ui/map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type MapType = 'hybrid' | 'roadmap' | 'satellite';
* @type object
* @inherits NativeEventInfo
*/
export type ClickEvent = NativeEventInfo<dxMap, MouseEvent | PointerEvent>;
export type ClickEvent = NativeEventInfo<dxMap, MouseEvent | PointerEvent> & { location: MapLocation };

/**
* @docid _ui_map_DisposingEvent
Expand Down
1 change: 1 addition & 0 deletions packages/devextreme/testing/helpers/forMap/googleMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
MouseEvent: function(latLng) {
this.stop = function() {};
this.latLng = latLng;
this.domEvent = true;
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,12 @@ QUnit.module('basic options', moduleConfig, () => {
assert.strictEqual(e.component, map, 'click event includes component instance');
assert.strictEqual($(e.element).is($('#map')), true, 'click event includes root element');
assert.deepEqual(e.location, { lat: 88, lng: 88 }, 'click event includes correct location');
assert.strictEqual(e.event, true, 'click event includes event instance');

clickFired++;
},
onReady: () => {
atlas.clickActionCallback({ type: 'click', position: [88, 88] });
atlas.clickActionCallback({ type: 'click', position: [88, 88], originalEvent: true });
assert.strictEqual(clickFired, 1, 'click action fired');

done();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,8 @@ QUnit.test('click', function(assert) {
provider: 'googleStatic',
width: 400,
height: 500,
onClick: function() {
onClick: function(e) {
assert.ok(e.event, 'click event includes event instance');
clicked++;
},
onReady: function(e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,7 @@ QUnit.test('click', function(assert) {
lat: 2,
lng: 10
}, 'correct location passed');
assert.strictEqual(e.event, true, 'click event includes event instance');
clicked++;
},
onReady: function() {
Expand Down
2 changes: 1 addition & 1 deletion packages/devextreme/ts/dx.all.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21074,7 +21074,7 @@ declare module DevExpress.ui {
export type ClickEvent = DevExpress.common.core.events.NativeEventInfo<
dxMap,
MouseEvent | PointerEvent
>;
> & { location: MapLocation };
/**
* [descr:_ui_map_DisposingEvent]
*/
Expand Down

0 comments on commit 498699b

Please sign in to comment.