Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import type { ColumnPoint } from '@ts/grids/grid_core/m_types';

import { isEqualSelectors, isSelectorEqualWithCallback } from './utils/index';

const BASE_LOAD_PANEL_Z_INDEX = 1000;

const DATAGRID_SELECTION_DISABLED_CLASS = 'dx-selection-disabled';
const DATAGRID_GROUP_OPENED_CLASS = 'dx-datagrid-group-opened';
const DATAGRID_GROUP_CLOSED_CLASS = 'dx-datagrid-group-closed';
Expand Down Expand Up @@ -230,6 +232,7 @@ export default {
shading: false,
message: loadPanelOptions.text,
container: $container,
zIndex: BASE_LOAD_PANEL_Z_INDEX,
}, loadPanelOptions);

that._loadPanel = that._createComponent($('<div>').appendTo($container), LoadPanel, loadPanelOptions);
Expand Down
44 changes: 33 additions & 11 deletions packages/devextreme/js/__internal/ui/overlay/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export interface OverlayProperties extends Properties {

templatesRenderAsynchronously?: boolean;

zIndex?: number;

_loopFocus?: boolean;

_ignorePreventScrollEventsDeprecation?: boolean;
Expand Down Expand Up @@ -877,25 +879,42 @@ class Overlay<
this._toggleSubscriptions(visible);
}

_handleZIndexOptionChanged(): void {
const { zIndex } = this.option();

this._zIndex = zIndex ?? zIndexPool.create(this._zIndexInitValue());

this._updateZIndexStackPosition(this._isVisible());
}

_updateZIndexStackPosition(pushToStack: boolean): void {
const overlayStack = this._overlayStack();
// @ts-expect-error this and Overlay have no overlap
const index = overlayStack.indexOf(this);
const isInStack = index !== -1;
const { zIndex } = this.option();

if (pushToStack) {
if (index === -1) {
this._zIndex = zIndexPool.create(this._zIndexInitValue());

// @ts-expect-error this and Overlay have no overlap
overlayStack.push(this);
if (!pushToStack) {
if (isInStack) {
overlayStack.splice(index, 1);
zIndexPool.remove(this._zIndex);
}

this._$wrapper.css('zIndex', this._zIndex);
this._$content.css('zIndex', this._zIndex);
} else if (index !== -1) {
overlayStack.splice(index, 1);
zIndexPool.remove(this._zIndex);
return;
}

if (!isInStack) {
this._zIndex = zIndex ?? zIndexPool.create(this._zIndexInitValue());
// @ts-expect-error this and Overlay have no overlap
overlayStack.push(this);
}

this._updateZIndex();
}

_updateZIndex(): void {
this._$wrapper.css('zIndex', this._zIndex);
this._$content.css('zIndex', this._zIndex);
}

_toggleShading(visible?: boolean): void {
Expand Down Expand Up @@ -1551,6 +1570,9 @@ class Overlay<
this._initHideTopOverlayHandler(value);
this._toggleHideTopOverlayCallback(this._isVisible());
break;
case 'zIndex':
this._handleZIndexOptionChanged();
break;
case 'hideOnParentScroll':
case '_hideOnParentScrollTarget': {
this._toggleHideOnParentsScrollSubscription(this._isVisible());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,21 @@ QUnit.module('Initialization', baseModuleConfig, () => {
// assert
assert.strictEqual(onContentReadySpy.callCount, 1, 'onContentReadySpy call count');
});

QUnit.test('Load panel has custom z-index (T1308742)', function(assert) {
const dataGrid = createDataGrid({
dataSource: {
load: function() {
return;
}
}
});

const loadPanel = dataGrid.getView('rowsView')._loadPanel;
const loadPanelZIndex = loadPanel._zIndex;

assert.strictEqual(loadPanelZIndex, 1000, 'load z-index is set to 1000 by default');
});
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,50 @@ testModule('API', moduleConfig, () => {
assert.strictEqual(resizeStub.callCount, 1, '\'dxresize\' event handler was called');
resizeStub.restore();
});

test('Overlay uses custom zIndex on init if zIndex option is provided', function(assert) {
const overlay = $('#overlay').dxOverlay({
visible: true,
zIndex: 2000
}).dxOverlay('instance');

const contentZIndex = Number(getComputedStyle(overlay.$content()[0]).zIndex);

assert.strictEqual(contentZIndex, 2000, 'custom zIndex assigned');
});

test('Changing zIndex option replaces old pool zIndex with custom', function(assert) {
const overlay = $('#overlay').dxOverlay({
visible: true
}).dxOverlay('instance');

const initialZIndex = Number(getComputedStyle(overlay.$content()[0]).zIndex);

assert.strictEqual(initialZIndex, 1501, 'overlay has initial pool zIndex');

overlay.option('zIndex', 5000);

const finalZIndex = Number(getComputedStyle(overlay.$content()[0]).zIndex);

assert.strictEqual(finalZIndex, 5000, 'custom zIndex applied');
});

test('Changing zIndex option to undefined resets the default pool zIndex', function(assert) {
const overlay = $('#overlay').dxOverlay({
visible: true,
zIndex: 5000
}).dxOverlay('instance');

const initialZIndex = Number(getComputedStyle(overlay.$content()[0]).zIndex);

assert.strictEqual(initialZIndex, 5000, 'overlay has custom zIndex');

overlay.option('zIndex', undefined);

const finalZIndex = Number(getComputedStyle(overlay.$content()[0]).zIndex);

assert.strictEqual(finalZIndex, 1501, 'initial pool zIndex applied');
});
});


Expand Down
Loading