Skip to content

Commit e00a6c9

Browse files
marker-daomarker dao ®
andauthored
Chat Suggestions: Clean suggestions when there are no items (DevExpress#33467)
Co-authored-by: marker dao ® <youdontknow@marker-dao.eth>
1 parent a8c31b1 commit e00a6c9

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/devextreme/js/__internal/ui/chat/suggestions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,18 @@ class Suggestions {
4040
}
4141

4242
private _initButtonGroup(options: SuggestionsOptions = {}): void {
43-
if (this._hasOptions(options) && this._$element) {
43+
if (this._hasItems(options) && this._$element) {
4444
this._$element.addClass(CHAT_SUGGESTIONS_CLASS);
4545
this._buttonGroup = new ButtonGroup(this._$element.get(0), this._getConfiguration(options));
4646
}
4747
}
4848

49-
private _hasOptions(options: SuggestionsOptions | undefined): boolean {
50-
return Boolean(Object.keys(options ?? {}).length);
49+
private _hasItems(options: SuggestionsOptions | undefined): boolean {
50+
return Boolean(options?.items?.length);
5151
}
5252

5353
updateOptions(options: SuggestionsOptions | undefined): void {
54-
if (!this._hasOptions(options)) {
54+
if (!this._hasItems(options)) {
5555
this.clean();
5656
return;
5757
}

packages/devextreme/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
"build:community-localization": "gulp generate-community-locales",
244244
"build:systemjs": "gulp transpile-systemjs",
245245
"dev": "cross-env DEVEXTREME_TEST_CI=true gulp dev",
246+
"dev:playground": "vite",
246247
"dev:watch": "cross-env DEVEXTREME_TEST_CI=true gulp dev-watch",
247248
"transpile-tests": "gulp transpile-tests",
248249
"update-ts-reexports": "dx-tools generate-reexports --sources ./js --exclude \"((dialog|export|list_light|notify|overlay|palette|set_template_engine|splitter_control|themes|themes_callback|track_bar|utils|validation_engine|validation_message)[.d.ts])\" --compiler-options \"{ \\\"typeRoots\\\": [] }\"",
@@ -251,7 +252,6 @@
251252
"validate-ts": "gulp validate-ts",
252253
"validate-declarations": "dx-tools validate-declarations --sources ./js --exclude \"js/(renovation|__internal|.eslintrc.js)\" --compiler-options \"{ \\\"typeRoots\\\": [] }\"",
253254
"testcafe-in-docker": "docker build -f ./testing/testcafe/docker/Dockerfile -t testcafe-testing . && docker run -it testcafe-testing",
254-
"dev:playground": "vite",
255255
"test-jest": "cross-env NODE_OPTIONS='--expose-gc' jest --no-coverage --runInBand --selectProjects jsdom-tests",
256256
"test-jest:watch": "jest --watch",
257257
"test-jest:node": "jest --no-coverage --runInBand --selectProjects node-tests",

packages/devextreme/testing/tests/DevExpress.ui.widgets/chatParts/suggestions.tests.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,11 @@ QUnit.module('Suggestions', moduleConfig, () => {
5353
assert.strictEqual(this.getItems().length, 1, 'item rendered correctly');
5454
});
5555

56-
QUnit.test('should update items to empty list', function(assert) {
56+
QUnit.test('should clean ButtonGroup when items is empty array', function(assert) {
5757
this.instance.updateOptions({ items: [] });
5858

59-
const $items = this.getItems();
60-
61-
assert.strictEqual($items.length, 0, 'all items removed');
59+
assert.strictEqual(this.getItems().length, 0, 'all items removed');
60+
assert.strictEqual(this.getSuggestions().hasClass(BUTTON_GROUP_CLASS), false, 'ButtonGroup is cleaned');
6261
});
6362

6463
QUnit.test('should clean ButtonGroup when called with undefined', function(assert) {

0 commit comments

Comments
 (0)