diff --git a/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.azure.ts b/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.azure.ts index 1165d3f93d33..2cdff9aef4b7 100644 --- a/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.azure.ts +++ b/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.azure.ts @@ -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, + }); } }, diff --git a/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.google.ts b/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.google.ts index 89cbc67f95e0..51ead8ca259b 100644 --- a/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.google.ts +++ b/packages/devextreme/js/__internal/ui/map/m_provider.dynamic.google.ts @@ -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() { diff --git a/packages/devextreme/js/ui/map.d.ts b/packages/devextreme/js/ui/map.d.ts index 159188f2b6a6..66c66f04a8e9 100644 --- a/packages/devextreme/js/ui/map.d.ts +++ b/packages/devextreme/js/ui/map.d.ts @@ -26,7 +26,10 @@ export type MapType = 'hybrid' | 'roadmap' | 'satellite'; * @type object * @inherits NativeEventInfo */ -export type ClickEvent = NativeEventInfo; +export type ClickEvent = NativeEventInfo & { + /** @docid _ui_map_ClickEvent.location */ + location: MapLocation; +}; /** * @docid _ui_map_DisposingEvent @@ -133,6 +136,7 @@ export type RouteRemovedEvent = EventInfo & { }; /** + * @docid * @public * @namespace DevExpress.ui */ diff --git a/packages/devextreme/js/ui/map.js b/packages/devextreme/js/ui/map.js index 1f6c407339d3..a2906756a583 100644 --- a/packages/devextreme/js/ui/map.js +++ b/packages/devextreme/js/ui/map.js @@ -48,11 +48,6 @@ export default Map; * @hidden */ -/** - * @name MapLocation - * @hidden - */ - /** * @name dxMapOptions.onContentReady * @hidden true diff --git a/packages/devextreme/testing/helpers/forMap/googleMock.js b/packages/devextreme/testing/helpers/forMap/googleMock.js index 6b4d3ad88c20..26832b155c0b 100644 --- a/packages/devextreme/testing/helpers/forMap/googleMock.js +++ b/packages/devextreme/testing/helpers/forMap/googleMock.js @@ -397,6 +397,7 @@ MouseEvent: function(latLng) { this.stop = function() {}; this.latLng = latLng; + this.domEvent = new MouseEvent({ type: 'click' }); } } }; diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/azureTests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/azureTests.js index 90cc386c11b9..38521a2cec09 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/azureTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/azureTests.js @@ -466,6 +466,7 @@ QUnit.module('basic options', moduleConfig, () => { QUnit.test('Should add onClick handler with correct args', function(assert) { const done = assert.async(); let clickFired = 0; + const originalEvent = new PointerEvent({ type: 'click' }); const map = $('#map').dxMap({ provider: 'azure', @@ -473,11 +474,16 @@ 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.deepEqual(e.event, originalEvent, 'click event is equal to passed originalEvent'); clickFired++; }, onReady: () => { - atlas.clickActionCallback({ type: 'click', position: [88, 88] }); + atlas.clickActionCallback({ + type: 'click', + position: [88, 88], + originalEvent, + }); assert.strictEqual(clickFired, 1, 'click action fired'); done(); diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js index 507b6a8c48e5..c44639e69854 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleStaticTests.js @@ -471,12 +471,17 @@ QUnit.test('click', function(assert) { let clicked = 0; let eventFired = 0; + const clickEvent = $.Event('click'); + return new Promise(function(resolve) { - new Map($('#map'), { + const map = new Map($('#map'), { provider: 'googleStatic', width: 400, height: 500, - onClick: function() { + onClick: function(e) { + assert.strictEqual(e.component, map, 'component is passed correctly'); + assert.strictEqual(e.element, map.$element(), 'element is passed correctly'); + assert.strictEqual(e.event.originalEvent, clickEvent, 'event is passed correctly'); clicked++; }, onReady: function(e) { @@ -484,7 +489,7 @@ QUnit.test('click', function(assert) { $element.dxMap('instance').on('click', function() { eventFired++; }); - $element.children().trigger('dxclick'); + $element.children().trigger(clickEvent); resolve(); } diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleTests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleTests.js index 09ed7908d2c8..d09fc0cc757b 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleTests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets/mapParts/googleTests.js @@ -1525,6 +1525,8 @@ QUnit.test('click', function(assert) { let clicked = 0; let eventFired = 0; + let mouseEvent; + const $map = $('#map').dxMap({ provider: 'google', width: 400, @@ -1534,6 +1536,7 @@ QUnit.test('click', function(assert) { lat: 2, lng: 10 }, 'correct location passed'); + assert.strictEqual(e.event, mouseEvent.domEvent, 'click event is equal to the original event'); clicked++; }, onReady: function() { @@ -1546,7 +1549,8 @@ QUnit.test('click', function(assert) { }); d.done(function() { - window.google.clickActionCallback(new google.maps.MouseEvent(new google.maps.LatLng(2, 10))); + mouseEvent = new google.maps.MouseEvent(new google.maps.LatLng(2, 10)); + window.google.clickActionCallback(mouseEvent); assert.equal(clicked, 1); assert.equal(eventFired, 1); done(); diff --git a/packages/devextreme/ts/dx.all.d.ts b/packages/devextreme/ts/dx.all.d.ts index 681a892b0e3e..8fd60fb252cc 100644 --- a/packages/devextreme/ts/dx.all.d.ts +++ b/packages/devextreme/ts/dx.all.d.ts @@ -21076,7 +21076,12 @@ declare module DevExpress.ui { export type ClickEvent = DevExpress.common.core.events.NativeEventInfo< dxMap, MouseEvent | PointerEvent - >; + > & { + /** + * [descr:_ui_map_ClickEvent.location] + */ + location: MapLocation; + }; /** * [descr:_ui_map_DisposingEvent] */ @@ -31047,6 +31052,9 @@ declare module DevExpress.ui { */ selectedExpr?: string | Function; } + /** + * [descr:MapLocation] + */ export interface MapLocation { /** * [descr:MapLocation.lat]