Skip to content

Commit 2d4847f

Browse files
authored
fix(dropdowns.next): active listbox option and menu item styling (#1655)
1 parent 382bf38 commit 2d4847f

File tree

8 files changed

+5252
-43977
lines changed

8 files changed

+5252
-43977
lines changed

.circleci/config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
steps:
2626
- checkout
2727
- node/install-packages:
28+
override-ci-command: npm ci --ignore-scripts
2829
cache-version: '{{ .Environment.CACHE_VERSION }}'
29-
- run: npm exec -- lerna run build --concurrency=1 # prevent out-of-memory
30+
- run: npm exec -- lerna run build --concurrency=2 # prevent out-of-memory
3031
- *persist_to_workspace
3132

3233
test:

package-lock.json

Lines changed: 5208 additions & 43950 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "@zendeskgarden/react-components",
44
"version": "0.0.0",
55
"scripts": {
6-
"build": "lerna run build --stream --concurrency=1",
6+
"build": "lerna run build --stream",
77
"build:demo": "storybook build -o ./demo",
88
"format": "prettier-package-json --write && npm run -- format:package_json --write && npm run -- format:js --write && npm run -- format:md --write",
99
"format:all": "prettier-package-json --list-different && npm run -- format:package_json --list-different && npm run -- format:js --check && npm run -- format:md --check",
@@ -38,10 +38,10 @@
3838
"@babel/preset-react": "7.22.15",
3939
"@babel/preset-typescript": "7.23.2",
4040
"@brodybits/rollup-plugin-size-snapshot": "0.15.0",
41-
"@rollup/plugin-babel": "5.3.1",
41+
"@rollup/plugin-babel": "6.0.4",
4242
"@rollup/plugin-commonjs": "25.0.7",
4343
"@rollup/plugin-node-resolve": "15.2.3",
44-
"@rollup/plugin-replace": "5.0.4",
44+
"@rollup/plugin-replace": "5.0.5",
4545
"@storybook/addon-a11y": "7.4.6",
4646
"@storybook/addon-designs": "7.0.5",
4747
"@storybook/addon-essentials": "7.4.6",
@@ -64,7 +64,7 @@
6464
"@typescript-eslint/parser": "6.8.0",
6565
"@zendeskgarden/css-bedrock": "9.1.1",
6666
"@zendeskgarden/eslint-config": "35.0.0",
67-
"@zendeskgarden/scripts": "2.0.2",
67+
"@zendeskgarden/scripts": "2.0.4",
6868
"@zendeskgarden/stylelint-config": "20.0.0",
6969
"@zendeskgarden/svg-icons": "7.0.0",
7070
"babel-plugin-module-resolver": "5.0.0",
@@ -106,7 +106,7 @@
106106
"react-is": "18.2.0",
107107
"react-test-renderer": "18.2.0",
108108
"regenerator-runtime": "0.14.0",
109-
"rollup": "4.1.4",
109+
"rollup": "4.4.1",
110110
"rollup-plugin-analyzer": "4.0.0",
111111
"rollup-plugin-cleanup": "3.2.1",
112112
"rollup-plugin-delete": "2.0.0",

packages/colorpickers/.size-snapshot.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"index.cjs.js": {
3-
"bundled": 55237,
3+
"bundled": 55263,
44
"minified": 36325,
55
"gzipped": 8536
66
},
77
"index.esm.js": {
8-
"bundled": 51385,
8+
"bundled": 51411,
99
"minified": 32708,
1010
"gzipped": 8272,
1111
"treeshaked": {

packages/colorpickers/src/elements/Colorpicker/ColorWell.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const ColorWell: React.FC<IColorWellProps> = React.memo(
9090
}, [throttledChange]);
9191

9292
return (
93+
/* eslint-disable-next-line jsx-a11y/prefer-tag-over-role */
9394
<StyledColorWell
9495
hue={hue}
9596
ref={containerRef}

packages/dropdowns.next/.size-snapshot.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"index.cjs.js": {
3-
"bundled": 73423,
4-
"minified": 52141,
5-
"gzipped": 11396
3+
"bundled": 73611,
4+
"minified": 52290,
5+
"gzipped": 11443
66
},
77
"index.esm.js": {
8-
"bundled": 67344,
9-
"minified": 46316,
10-
"gzipped": 10759,
8+
"bundled": 67519,
9+
"minified": 46452,
10+
"gzipped": 10807,
1111
"treeshaked": {
1212
"rollup": {
13-
"code": 36385,
13+
"code": 36514,
1414
"import_statements": 1174
1515
},
1616
"webpack": {
17-
"code": 40077
17+
"code": 40219
1818
}
1919
}
2020
}

packages/dropdowns.next/src/elements/combobox/Combobox.spec.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import React, { HTMLAttributes, InputHTMLAttributes, forwardRef } from 'react';
9-
import { render } from 'garden-test-utils';
9+
import { render, renderRtl } from 'garden-test-utils';
1010
import userEvent from '@testing-library/user-event';
1111
import { PALETTE } from '@zendeskgarden/react-theming';
1212
import { IComboboxProps, ISelectedOption } from '../../types';
@@ -147,6 +147,18 @@ describe('Combobox', () => {
147147
const option = getByTestId('option');
148148

149149
expect(input).toHaveAttribute('aria-activedescendant', option.id);
150+
expect(option).toHaveStyleRule('box-shadow', expect.stringContaining('inset 3px'));
151+
});
152+
153+
it('handles active index RTL as expected', () => {
154+
const { getByTestId } = renderRtl(
155+
<TestCombobox defaultExpanded defaultActiveIndex={0}>
156+
<Option data-test-id="option" value="active" />
157+
</TestCombobox>
158+
);
159+
const option = getByTestId('option');
160+
161+
expect(option).toHaveStyleRule('box-shadow', expect.stringContaining('inset -3px'));
150162
});
151163

152164
it('applies `id` as expected', () => {

packages/dropdowns.next/src/views/combobox/StyledOption.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,18 @@ export interface IStyledOptionProps extends ThemeProps<DefaultTheme> {
1919
}
2020

2121
const colorStyles = (props: IStyledOptionProps) => {
22-
const activeBackgroundColor = getColor(
23-
props.$type === 'danger' ? 'dangerHue' : 'primaryHue',
24-
600,
25-
props.theme,
26-
0.08
27-
);
28-
const backgroundColor =
29-
props.isActive && props.$type !== 'group' && props.$type !== 'header'
30-
? activeBackgroundColor
31-
: undefined;
22+
let backgroundColor;
23+
let boxShadow;
24+
25+
if (props.isActive && props.$type !== 'group' && props.$type !== 'header') {
26+
const hue = props.$type === 'danger' ? 'dangerHue' : 'primaryHue';
27+
28+
backgroundColor = getColor(hue, 600, props.theme, 0.08);
29+
boxShadow = `inset ${
30+
props.theme.rtl ? `-${props.theme.shadowWidths.md}` : props.theme.shadowWidths.md
31+
} 0 ${getColor(hue, 600, props.theme)}`;
32+
}
33+
3234
const disabledForegroundColor = getColor('neutralHue', 400, props.theme);
3335
let foregroundColor = props.theme.colors.foreground;
3436

@@ -39,6 +41,7 @@ const colorStyles = (props: IStyledOptionProps) => {
3941
}
4042

4143
return css`
44+
box-shadow: ${boxShadow};
4245
background-color: ${backgroundColor};
4346
color: ${foregroundColor};
4447

0 commit comments

Comments
 (0)