From fdf0b21b7473e3416e7b5008afc8e400993289b0 Mon Sep 17 00:00:00 2001
From: sai6855 <60743144+sai6855@users.noreply.github.com>
Date: Sun, 3 Sep 2023 20:50:14 +0530
Subject: [PATCH 01/16] fix
---
packages/mui-base/src/Select/Select.test.tsx | 20 ++++++++++++++++++++
packages/mui-base/src/useList/listReducer.ts | 3 ++-
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/packages/mui-base/src/Select/Select.test.tsx b/packages/mui-base/src/Select/Select.test.tsx
index 852a8cf090ca63..1c8bc6a6febce0 100644
--- a/packages/mui-base/src/Select/Select.test.tsx
+++ b/packages/mui-base/src/Select/Select.test.tsx
@@ -1234,4 +1234,24 @@ describe('', () => {
expect(renderOption3Spy.callCount).to.equal(0);
expect(renderOption4Spy.callCount).to.equal(0);
});
+
+ it('option should have highlighted class only when it is selected', () => {
+ const { getAllByRole } = render(
+ ,
+ );
+
+ const option = getAllByRole('option')[1];
+
+ // selects option
+ fireEvent.click(option);
+ expect(option).to.have.class(optionClasses.highlighted);
+ // deselects option
+ fireEvent.click(option);
+ expect(option).not.to.have.class(optionClasses.highlighted);
+ });
});
diff --git a/packages/mui-base/src/useList/listReducer.ts b/packages/mui-base/src/useList/listReducer.ts
index bfce751beb5567..202b877bbaad62 100644
--- a/packages/mui-base/src/useList/listReducer.ts
+++ b/packages/mui-base/src/useList/listReducer.ts
@@ -217,10 +217,11 @@ function handleItemSelection>(
// if the item is already selected, remove it from the selection, otherwise add it
const newSelectedValues = toggleSelection(item, selectedValues, selectionMode, itemComparer);
+ const highlightedValue = selectedValues.includes(items[itemIndex]) ? null : item;
return {
...state,
selectedValues: newSelectedValues,
- highlightedValue: item,
+ highlightedValue,
};
}
From 5dcc93557cff4ba368277f048a8c4fcd157da518 Mon Sep 17 00:00:00 2001
From: sai6855 <60743144+sai6855@users.noreply.github.com>
Date: Sun, 3 Sep 2023 20:53:21 +0530
Subject: [PATCH 02/16] fix tests
---
packages/mui-base/src/Select/Select.test.tsx | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/packages/mui-base/src/Select/Select.test.tsx b/packages/mui-base/src/Select/Select.test.tsx
index 1c8bc6a6febce0..88292eed9d64ff 100644
--- a/packages/mui-base/src/Select/Select.test.tsx
+++ b/packages/mui-base/src/Select/Select.test.tsx
@@ -1245,13 +1245,16 @@ describe('', () => {
,
);
- const option = getAllByRole('option')[1];
+ const options = getAllByRole('option');
+ const secondOption = options[1];
+ // it doesn't have highlighted class as it is not selected
+ expect(secondOption).not.to.have.class(optionClasses.highlighted);
// selects option
- fireEvent.click(option);
- expect(option).to.have.class(optionClasses.highlighted);
+ fireEvent.click(secondOption);
+ expect(secondOption).to.have.class(optionClasses.highlighted);
// deselects option
- fireEvent.click(option);
- expect(option).not.to.have.class(optionClasses.highlighted);
+ fireEvent.click(secondOption);
+ expect(secondOption).not.to.have.class(optionClasses.highlighted);
});
});
From 4a81c8c83bc1195a11f8560452b28137978237b5 Mon Sep 17 00:00:00 2001
From: sai6855 <60743144+sai6855@users.noreply.github.com>
Date: Sun, 3 Sep 2023 20:53:36 +0530
Subject: [PATCH 03/16] fix tests
---
packages/mui-base/src/Select/Select.test.tsx | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/mui-base/src/Select/Select.test.tsx b/packages/mui-base/src/Select/Select.test.tsx
index 88292eed9d64ff..f6f01758627fe5 100644
--- a/packages/mui-base/src/Select/Select.test.tsx
+++ b/packages/mui-base/src/Select/Select.test.tsx
@@ -1247,6 +1247,7 @@ describe('', () => {
const options = getAllByRole('option');
const secondOption = options[1];
+
// it doesn't have highlighted class as it is not selected
expect(secondOption).not.to.have.class(optionClasses.highlighted);
From 4d90bb3486837e55008a722e0edfa2c9b62fc42d Mon Sep 17 00:00:00 2001
From: sai6855 <60743144+sai6855@users.noreply.github.com>
Date: Sun, 3 Sep 2023 21:41:08 +0530
Subject: [PATCH 04/16] more tests
---
packages/mui-base/src/Select/Select.test.tsx | 36 ++++++++++++++++++--
1 file changed, 33 insertions(+), 3 deletions(-)
diff --git a/packages/mui-base/src/Select/Select.test.tsx b/packages/mui-base/src/Select/Select.test.tsx
index f6f01758627fe5..6beb96ce3aa4a7 100644
--- a/packages/mui-base/src/Select/Select.test.tsx
+++ b/packages/mui-base/src/Select/Select.test.tsx
@@ -1235,9 +1235,29 @@ describe('', () => {
expect(renderOption4Spy.callCount).to.equal(0);
});
- it('option should have highlighted class only when it is selected', () => {
- const { getAllByRole } = render(
-