Skip to content

Commit 5b971c5

Browse files
authored
T1301121 - double fileManager - popup notification is not positioned correctly (#30521)
1 parent 9222085 commit 5b971c5

File tree

4 files changed

+89
-2
lines changed

4 files changed

+89
-2
lines changed

packages/devextreme/js/ui/file_manager/ui.file_manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class FileManager extends Widget {
101101
progressPanelContainer: this.$element(),
102102
contentTemplate: (container, notificationControl) => this._createWrapper(container, notificationControl),
103103
onActionProgress: e => this._onActionProgress(e),
104-
positionTarget: `.${FILE_MANAGER_CONTAINER_CLASS}`,
104+
positionTargetSelector: `.${FILE_MANAGER_CONTAINER_CLASS}`,
105105
showProgressPanel: this.option('notifications.showPanel'),
106106
showNotificationPopup: this.option('notifications.showPopup')
107107
});

packages/devextreme/js/ui/file_manager/ui.file_manager.notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ export default class FileManagerNotificationControl extends Widget {
291291
position: {
292292
my: 'right top',
293293
at: 'right top',
294-
of: this.option('positionTarget'),
294+
of: this._progressDrawer.$element().find(this.option('positionTargetSelector')),
295295
offset: '-10 -5'
296296
},
297297
_wrapperClassExternal: FILE_MANAGER_NOTIFICATION_POPUP_CLASS,

packages/devextreme/testing/helpers/fileManagerHelpers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ export class FileManagerWrapper {
130130
return this._$element.find(`.${Consts.ITEMS_PANEL_CLASS}`);
131131
}
132132

133+
getContainer() {
134+
return this._$element.find(`.${Consts.CONTAINER_CLASS}`);
135+
}
136+
133137
getFolderNodes(inDialog) {
134138
if(inDialog) {
135139
return this.getFolderChooserDialog().find(`.${Consts.DIALOG_CLASS} .${Consts.FOLDERS_TREE_VIEW_ITEM_CLASS}`);
@@ -517,6 +521,10 @@ export class FileManagerWrapper {
517521
return $(`.${Consts.NOTIFICATION_POPUP_CLASS} .${Consts.POPUP_NORMAL_CLASS}`);
518522
}
519523

524+
getNotificationPopupInstance() {
525+
return this.getInstance()._notificationControl._notificationPopup;
526+
}
527+
520528
getFolderChooserDialog() {
521529
return $(`.${Consts.FOLDER_CHOOSER_DIALOG_CLASS} .${Consts.POPUP_NORMAL_CLASS}`).filter(':visible');
522530
}

packages/devextreme/testing/tests/DevExpress.ui.widgets/fileManagerParts/editing.tests.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,62 @@ const moduleConfig = {
6464
}
6565
};
6666

67+
const moduleConfig_T1301121 = {
68+
beforeEach: function() {
69+
const markup = '<div style="display: flex; flex-flow: column nowrap;"><div id="file-manager-1"></div><div id="file-manager-2"></div></div>';
70+
$('#qunit-fixture').html(markup);
71+
72+
this.clock = sinon.useFakeTimers();
73+
fx.off = true;
74+
75+
const createProvider = fileManagerName => new CustomFileSystemProvider({
76+
getItems: parent => {
77+
if(fileManagerName === 'fileManager2') {
78+
return Promise.reject(new FileSystemError(42, parent, 'You have no access to this folder.'));
79+
}
80+
return [
81+
{
82+
name: 'Folder 1',
83+
isDirectory: true,
84+
hasSubDirectories: false
85+
}
86+
];
87+
},
88+
});
89+
90+
const getFmOptions = rootFolderName => ({
91+
name: rootFolderName,
92+
rootFolderName: rootFolderName,
93+
fileSystemProvider: createProvider(rootFolderName),
94+
notifications: {
95+
showPanel: true,
96+
showPopup: true
97+
}
98+
});
99+
100+
this.$fMElement1 = $('#file-manager-1').dxFileManager(getFmOptions('fileManager1'));
101+
this.$fMElement2 = $('#file-manager-2').dxFileManager(getFmOptions('fileManager2'));
102+
103+
this.fileManager1 = this.$fMElement1.dxFileManager('instance');
104+
this.fileManager2 = this.$fMElement2.dxFileManager('instance');
105+
106+
this.wrapper1 = new FileManagerWrapper(this.$fMElement1);
107+
this.wrapper2 = new FileManagerWrapper(this.$fMElement2);
108+
this.progressPanelWrapper1 = new FileManagerProgressPanelWrapper(this.$fMElement1);
109+
this.progressPanelWrapper2 = new FileManagerProgressPanelWrapper(this.$fMElement2);
110+
this.clock.tick(400);
111+
},
112+
113+
afterEach: function() {
114+
this.clock.tick(5000);
115+
116+
this.clock.restore();
117+
fx.off = false;
118+
119+
FileUploaderInternals.resetFileInputTag();
120+
}
121+
};
122+
67123
QUnit.module('Editing operations', moduleConfig, () => {
68124

69125
test('rename folder in folders area', function(assert) {
@@ -2457,3 +2513,26 @@ QUnit.module('Editing operations', moduleConfig, () => {
24572513
fx.off = true;
24582514
});
24592515
});
2516+
2517+
QUnit.module('double FileManager - notification displayed next to correct FileManager (Bugs)', moduleConfig_T1301121, () => {
2518+
2519+
test('error in second filemanager displayed in the popup located next to second filemanager', function(assert) {
2520+
this.clock.tick(800);
2521+
2522+
const $popupContents = this.wrapper2.getNotificationPopup();
2523+
const popupInstance = this.wrapper2.getNotificationPopupInstance();
2524+
2525+
assert.strictEqual(this.progressPanelWrapper1.getInfos().length, 0, 'There is no notifications on panel of first filemanager');
2526+
assert.strictEqual(this.progressPanelWrapper2.getInfos().length, 1, 'There is one notification on panel of second filemanager');
2527+
2528+
assert.ok($popupContents.is(':visible'), 'notification popup is visible');
2529+
const popupTop = $popupContents[0].getBoundingClientRect().top;
2530+
const popupLeft = $popupContents[0].getBoundingClientRect().left;
2531+
const fileManager2Top = this.$fMElement2[0].getBoundingClientRect().top;
2532+
const fileManager2Left = this.$fMElement2[0].getBoundingClientRect().left;
2533+
assert.true(popupTop > fileManager2Top, `notification popup is visible below second filemanager upper border (${popupTop} > ${fileManager2Top})`);
2534+
assert.true(popupLeft > fileManager2Left, `notification popup is visible to the right of second filemanager (${popupLeft} > ${fileManager2Left})`);
2535+
assert.true(this.wrapper2.getContainer()[0].isEqualNode(popupInstance.option('position').of[0]), 'notification popup position is correct');
2536+
});
2537+
2538+
});

0 commit comments

Comments
 (0)