diff --git a/packages/crayons-core/src/components/select-option/select-option.e2e.ts b/packages/crayons-core/src/components/select-option/select-option.e2e.ts index 947810d35..65721fbd1 100644 --- a/packages/crayons-core/src/components/select-option/select-option.e2e.ts +++ b/packages/crayons-core/src/components/select-option/select-option.e2e.ts @@ -126,4 +126,29 @@ describe('fw-select-option', () => { expect(metaText.email).toBe('author@example.com'); expect(metaText.mobile).toBe('123-456-7890'); }); + + it('should render fw-select-option with no variant and verify attributes', async () => { + const page = await newE2EPage(); + + await page.setContent( + ` + ` + ); + + await page.waitForChanges(); + + const text = await page.find('fw-select-option >>> .description'); + expect(text).toBeTruthy(); + expect(text.innerText).toBe('This is a select option description'); + + const metaText = await page.$eval('fw-select-option', (elm: any) => + JSON.parse(elm.getAttribute('data-meta-text')) + ); + expect(metaText.name).toBe('Author Name'); + expect(metaText.email).toBe('author@example.com'); + expect(metaText.mobile).toBe('123-456-7890'); + }); }); diff --git a/packages/crayons-core/src/components/select-option/select-option.scss b/packages/crayons-core/src/components/select-option/select-option.scss index 48f27fbda..e1a86ef95 100644 --- a/packages/crayons-core/src/components/select-option/select-option.scss +++ b/packages/crayons-core/src/components/select-option/select-option.scss @@ -133,3 +133,9 @@ $bg-color-disabled: $color-smoke-25; width: 1.25rem; height: 1.25rem; } + +.conversation-icon { + display: flex; + align-self: flex-start; + min-height: 30px; +} diff --git a/packages/crayons-core/src/components/select-option/select-option.tsx b/packages/crayons-core/src/components/select-option/select-option.tsx index fd45bb87b..6216e8996 100644 --- a/packages/crayons-core/src/components/select-option/select-option.tsx +++ b/packages/crayons-core/src/components/select-option/select-option.tsx @@ -188,8 +188,8 @@ export class SelectOption { return ( {checkbox} - {this.createIcon()} - {this.createConversationDescription()} + {this.createConversationIcon()} + {description} {selectedIconContainer} ); @@ -205,6 +205,24 @@ export class SelectOption { } createDescription() { + if (this.metaText) { + const metaTextDetails = []; + if (this.metaText?.name) metaTextDetails.push(this.metaText.name); + if (this.metaText?.email) metaTextDetails.push(this.metaText.email); + if (this.metaText?.mobile) metaTextDetails.push(this.metaText.mobile); + + return ( +
+ {this.text} + {this.subText && ( + {this.subText} + )} + + {metaTextDetails?.join(' | ')} + +
+ ); + } return this.subText ? (
- {this.text} - {this.subText} - - {metaTextDetails?.join(' | ')} - -
- ) : ( - {this.text} - ); + createConversationIcon() { + return
{this.createIcon()}
; } createIcon() {