Skip to content

Commit 74aaa63

Browse files
authored
DataGrid - AI Column: Hide AIPromptEditor when resizing a column (#31654)
Co-authored-by: Alyar <>
1 parent 007d9f5 commit 74aaa63

5 files changed

Lines changed: 64 additions & 1 deletion

File tree

e2e/testcafe-devextreme/tests/dataGrid/common/aiColumn/columnResizing.functional.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,51 @@ test('DropDownButton should be hidden during resizing', async (t) => {
218218
{ dataField: 'value', caption: 'Value' },
219219
],
220220
}));
221+
222+
test('AIPromptEditor should be hidden during resizing', async (t) => {
223+
// arrange
224+
const dataGrid = new DataGrid(DATA_GRID_SELECTOR);
225+
const aiDropDownButton = dataGrid
226+
.getHeaders()
227+
.getHeaderRow(0)
228+
.getCommandCell(0)
229+
.getAIDropDownButton();
230+
const aiPromptEditor = dataGrid.getAIPromptEditor();
231+
232+
await t.expect(dataGrid.isReady()).ok();
233+
234+
// act
235+
await t.click(aiDropDownButton.element);
236+
237+
// assert
238+
await t.expect(await aiDropDownButton.isOpened()).ok();
239+
240+
// act
241+
await t.click((await aiDropDownButton.getList()).getItem(0).element);
242+
243+
// assert
244+
await t.expect(aiPromptEditor.isVisible()).ok();
245+
246+
// act
247+
await dataGrid.resizeHeader(1, 50);
248+
249+
// assert
250+
await t.expect(aiPromptEditor.isVisible()).notOk();
251+
}).before(async () => createWidget('dxDataGrid', {
252+
dataSource: [
253+
{ id: 1, name: 'Name 1', value: 10 },
254+
{ id: 2, name: 'Name 2', value: 20 },
255+
{ id: 3, name: 'Name 3', value: 30 },
256+
],
257+
allowColumnResizing: true,
258+
columnWidth: 450,
259+
columns: [
260+
{
261+
type: 'ai',
262+
caption: 'AI Column',
263+
name: 'myAIColumn',
264+
alignment: 'right',
265+
},
266+
{ dataField: 'id', caption: 'ID' },
267+
],
268+
}));

packages/devextreme/js/__internal/grids/grid_core/ai_column/m_ai_column_view.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,13 @@ export const columnHeadersViewExtender = (
175175

176176
this.columnsResizer.resizeStarted.add(() => {
177177
/**
178-
* We need to manually close the DropDownMenu button
178+
* We need to manually close the DropDownMenu button and AIPromptEditor
179179
* because the stopPropagation method is called
180180
* when the cell resize is initiated.
181181
* Calling this method is necessary to fix bug T252661.
182182
*/
183183
this.activeDropDownButtonInstance?.close();
184+
this.aiPromptEditorController.hide();
184185
});
185186

186187
this.aiColumnOptionChangedHandler = this.aiColumnOptionChanged.bind(this);

packages/devextreme/js/__internal/grids/grid_core/ai_column/m_ai_prompt_editor_view_controller.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ export class AIPromptEditorViewController extends ViewController {
1515
): Promise<boolean> {
1616
return this.aiPromptEditorView.show(cellElement, column);
1717
}
18+
19+
public hide(): Promise<boolean> {
20+
return this.aiPromptEditorView.hide();
21+
}
1822
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Popup from '../popup';
2+
3+
export class AIPromptEditor extends Popup {
4+
}

packages/testcafe-models/dataGrid/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import TextBox from '../textBox';
2121
import { GroupPanel } from './groupPanel';
2222
import GridCore from '../gridCore';
2323
import { CLASS as CLASS_BASE } from '../gridCore';
24+
import { AIPromptEditor } from './aiPromptEditor';
2425

2526
export const CLASS = {
2627
...CLASS_BASE,
@@ -72,6 +73,7 @@ export const CLASS = {
7273
columnsSeparator: 'dx-datagrid-columns-separator',
7374
toast: 'dx-toast-wrapper',
7475
dragHeader: 'drag-header',
76+
aiPromptEditor: 'dx-ai-prompt-editor',
7577
};
7678

7779
const E2E_ATTRIBUTES = {
@@ -939,4 +941,8 @@ export default class DataGrid extends GridCore {
939941
getDraggableHeader() {
940942
return this.body.find(`.${this.addWidgetPrefix(CLASS.dragHeader)}`);
941943
}
944+
945+
getAIPromptEditor(): AIPromptEditor {
946+
return new AIPromptEditor(this.body.find(`.${CLASS.aiPromptEditor}`));
947+
}
942948
}

0 commit comments

Comments
 (0)