Skip to content

Commit f688b53

Browse files
committed
refactor(chat): remove containers when they are empty
1 parent f160851 commit f688b53

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/components/chat/chat-input.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,10 @@ export default class IgcChatInputComponent extends LitElement {
327327
protected override render() {
328328
return html`
329329
<div part="input-container" class="${this.dragClass}">
330-
${this.renderAttachmentsArea()}
330+
${this._chatState?.inputAttachments &&
331+
this._chatState?.inputAttachments.length > 0
332+
? this.renderAttachmentsArea()
333+
: nothing}
331334
332335
<div part="input-wrapper">
333336
${this._chatState?.options?.templates?.textInputTemplate

src/components/chat/chat.spec.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,6 @@ describe('Chat', () => {
201201
<slot name="empty-state">
202202
</slot>
203203
</div>
204-
<div aria-label="Suggestions" part="suggestions-container" role="list">
205-
<slot name="suggestions-header" part="suggestions-header"> </slot>
206-
<slot name="suggestions" part="suggestions">
207-
</slot>
208-
</div>
209204
<igc-chat-input>
210205
</igc-chat-input>
211206
</div>`
@@ -215,8 +210,6 @@ describe('Chat', () => {
215210

216211
expect(inputArea).shadowDom.to.equal(
217212
`<div part="input-container">
218-
<div aria-label="Attachments" part="attachments" role="list">
219-
</div>
220213
<div part="input-wrapper">
221214
<igc-textarea
222215
part="text-input"
@@ -496,8 +489,6 @@ describe('Chat', () => {
496489

497490
expect(inputArea).shadowDom.to.equal(
498491
`<div part="input-container">
499-
<div aria-label="Attachments" part="attachments" role="list">
500-
</div>
501492
<div part="input-wrapper">
502493
<igc-textarea
503494
part="text-input"

src/components/chat/chat.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ContextProvider } from '@lit/context';
2-
import { html, LitElement, type TemplateResult } from 'lit';
2+
import { html, LitElement, nothing, type TemplateResult } from 'lit';
33
import { property, query } from 'lit/decorators.js';
44
import { addThemingController } from '../../theming/theming-controller.js';
55
import IgcButtonComponent from '../button/button.js';
@@ -293,7 +293,10 @@ export default class IgcChatComponent extends EventEmitterMixin<
293293
<slot name="empty-state"> </slot>
294294
</div>`
295295
: html`<igc-chat-message-list> </igc-chat-message-list>`}
296-
${this.renderSuggestions()}
296+
${this._chatState.options?.suggestions &&
297+
this._chatState.options?.suggestions?.length > 0
298+
? this.renderSuggestions()
299+
: nothing}
297300
<igc-chat-input></igc-chat-input>
298301
</div>
299302
`;

0 commit comments

Comments
 (0)