Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
moathabuhamad-cengage committed Nov 25, 2024
1 parent 1e6333a commit 0049174
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ describe('Select', () => {
fireEvent.click(renderedSelect);

expect(getByText('Red')).toHaveAttribute('aria-disabled', 'true');
expect(getByText('Red')).toHaveStyleRule('cursor', 'not-allowed');
expect(getByText('Blue')).toHaveAttribute('aria-disabled', 'false');
expect(getByText('Green')).toHaveAttribute('aria-disabled', 'false');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function MultiSelect<T>(props: MultiSelectProps<T>) {
i => itemToString(i) === itemToString(itemToCheck)
);

return !isItemDisabled(itemToCheck) && itemIndex !== -1;
return !isItemDisabled(itemToCheck) && itemIndex !== -1 && !isItemDisabled(items[itemIndex]);
}

function getFilteredItemIndex(item: T, filteredItems: T[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,6 @@ describe('Select', () => {
fireEvent.click(renderedSelect);

expect(getByText('Red')).toHaveAttribute('aria-disabled', 'true');
expect(getByText('Red')).toHaveStyleRule('cursor', 'not-allowed');
expect(getByText('Blue')).toHaveAttribute('aria-disabled', 'false');
expect(getByText('Green')).toHaveAttribute('aria-disabled', 'false');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/react-magma-dom/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function Select<T>(props: SelectProps<T>) {
i => itemToString(i) === itemToString(itemToCheck)
);

if (itemIndex === -1 || isItemDisabled(itemToCheck)) {
if (itemIndex === -1 || isItemDisabled(itemToCheck) || isItemDisabled(items[itemIndex])) {
return { [key]: null };
}

Expand Down
8 changes: 8 additions & 0 deletions packages/react-magma-dom/src/components/Select/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ export const SelectedItemButton = styled.button<{
position: relative;
white-space: nowrap;
min-width: 0%;
outline-offset: 2px;
&:focus {
outline: 2px solid
${props =>
props.isInverse
? props.theme.colors.focusInverse
: props.theme.colors.focus};
}
`;

export const IconWrapper = styled.span`
Expand Down

0 comments on commit 0049174

Please sign in to comment.