Conversation
b125bca to
c1a86d0
Compare
| this._$element?.empty(); | ||
| } | ||
|
|
||
| dispose(): void { |
There was a problem hiding this comment.
Suggestions.dispose() removes _$element but doesn’t clear/dispose _buttonGroup (it only sets _$element to undefined). Even if dxremove ends up disposing the widget, keeping a reference to the ButtonGroup instance can retain memory and makes the lifecycle less explicit. Consider calling clean() (or at least setting _buttonGroup = undefined) as part of dispose() so the internal state is fully released and can’t be used accidentally after disposal.
| dispose(): void { | |
| dispose(): void { | |
| this.clean(); |
| // this.getSuggestionsElement = () => $(); | ||
| this.getSuggestionsElement = () => this.instance._suggestions._$element; | ||
| this.getSuggestionItems = () => this.$element.find(`.${BUTTON_GROUP_ITEM_CLASS}`); |
There was a problem hiding this comment.
The test helper accesses this.instance._suggestions._$element, which reaches into Suggestions internals (including a field marked private in TypeScript). This is brittle and can break if the implementation changes (e.g., renaming the field or switching to #private). Prefer querying the DOM for the suggestions container (e.g. by a stable CSS class) or exposing a small public accessor on Suggestions/Chat specifically for tests.
| // this.getSuggestionsElement = () => $(); | |
| this.getSuggestionsElement = () => this.instance._suggestions._$element; | |
| this.getSuggestionItems = () => this.$element.find(`.${BUTTON_GROUP_ITEM_CLASS}`); | |
| this.getSuggestionsElement = () => this.$element | |
| .find(`.${BUTTON_GROUP_ITEM_CLASS}`) | |
| .closest(`.${WIDGET_CLASS}`) | |
| .first(); | |
| this.getSuggestionItems = () => this.getSuggestionsElement().find(`.${BUTTON_GROUP_ITEM_CLASS}`); |
| this.getMessageListEmptyView = () => this.$element.find(`.${CHAT_MESSAGELIST_EMPTY_VIEW_CLASS}`); | ||
| this.getFileUploader = () => FileUploader.getInstance(this.$element.find(`.${FILEUPLOADER_CLASS}`)); | ||
| this.getAttachButton = () => Button.getInstance(this.$element.find(`.${CHAT_TEXT_AREA_ATTACH_BUTTON}`)); | ||
| // this.getSuggestionsElement = () => $(); |
There was a problem hiding this comment.
There is a leftover commented-out helper (// this.getSuggestionsElement = () => $();). Since it’s not used anymore, removing it would avoid noise in this shared test setup.
| // this.getSuggestionsElement = () => $(); |
| clean(): void { | ||
| this._buttonGroup?.dispose(); | ||
| this._buttonGroup = undefined; | ||
| this._$element?.empty(); | ||
| } |
There was a problem hiding this comment.
Suggestions.clean() disposes the ButtonGroup instance but leaves the ButtonGroup root CSS classes (e.g. dx-buttongroup, mode classes) on _$element. DevExtreme widgets typically do not remove root classes on dispose(), so after updateOptions(undefined/{}) the element will still look like a ButtonGroup, which contradicts the tests here and can leave incorrect styling when suggestions are cleared/reinitialized. Consider removing ButtonGroup-related classes/attributes from _$element (and optionally dx-chat-suggestions) when cleaning, so the element returns to a plain container state.
No description provided.