Skip to content

Commit 71ec231

Browse files
Merge pull request #346 from otto-de/BLA-626
fix(input-list): [BLA-626] fixes input list with text bug
2 parents 8d93abf + 0131ef2 commit 71ec231

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

packages/core-components/src/components/input-list/input-list.e2e.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,32 @@ describe('B2B-InputList', () => {
3535
expect(inputValue).toBe('8');
3636
});
3737

38-
it('should not receive input text when disabled', async () => {
38+
it('should not receive input text when disabled & should not show close icon', async () => {
3939
const inputList = await page.find('b2b-input-list');
40-
4140
inputList.setAttribute('disabled', true);
4241
await page.waitForChanges();
4342

4443
await typeInput();
4544

4645
let inputValue = inputList.getAttribute('value');
4746
expect(inputValue).toBe(null);
47+
const closeIcon = await page.find('b2b-input-list >>> b2b-icon');
48+
expect(closeIcon).toBeNull();
49+
});
50+
51+
it('should not not show close icon when input list has text and is disabled', async () => {
52+
await typeInput('b');
53+
await typeInput('2');
54+
await typeInput('b');
55+
const inputList = await page.find('b2b-input-list');
56+
57+
inputList.setAttribute('disabled', true);
58+
await page.waitForChanges();
59+
60+
let inputValue = inputList.getAttribute('value');
61+
expect(inputValue).toBe('b2b');
62+
const closeIcon = await page.find('b2b-input-list >>> b2b-icon');
63+
expect(closeIcon).toBeNull();
4864
});
4965

5066
it('should not show search list when input is not focused', async () => {

packages/core-components/src/components/input-list/input-list.stories.tsx

+31-2
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,50 @@ export const Focused: Story = {
4848
},
4949
};
5050

51-
export const Disabled: Story = {
51+
export const CustomList: Story = {
52+
args: {
53+
...meta.args,
54+
},
55+
render: ({ ...args }) => html`<div style="height: 130px; width: 300px">
56+
<b2b-input-list
57+
data-testid="element"
58+
label="${args.label}"
59+
required="${args.required}"
60+
placeholder="${args.placeholder}"
61+
disabled="${args.disabled}"
62+
.optionsList=${args.optionsList}
63+
><ul>
64+
<li>Option 1</li>
65+
<li>
66+
Option 2
67+
<ul>
68+
<li>Option 2.1</li>
69+
<li>Option 2.2</li>
70+
</ul>
71+
</li>
72+
<li>Option 3</li>
73+
</ul></b2b-input-list
74+
>
75+
</div>`,
76+
};
77+
78+
export const DisabledWithoutSelectedOption: Story = {
5279
args: {
5380
...meta.args,
5481
disabled: true,
5582
},
5683
};
5784

58-
export const CustomList: Story = {
85+
export const disabledWithSelectedOption: Story = {
5986
args: {
6087
...meta.args,
88+
disabled: true,
6189
},
6290
render: ({ ...args }) => html`<div style="height: 130px; width: 300px">
6391
<b2b-input-list
6492
data-testid="element"
6593
label="${args.label}"
94+
value="${args.optionsList[0]}"
6695
required="${args.required}"
6796
placeholder="${args.placeholder}"
6897
disabled="${args.disabled}"

packages/core-components/src/components/input-list/input-list.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class InputListComponent {
222222
onb2b-input={this.handleInput}
223223
placeholder={this.placeholder}
224224
required={this.required}>
225-
{Boolean(this.value) && (
225+
{!(this.disabled || this.groupDisabled) && Boolean(this.value) && (
226226
<b2b-icon
227227
icon="b2b_icon-close"
228228
aria-label="reset"

0 commit comments

Comments
 (0)