Skip to content

Commit 991fa9d

Browse files
committed
PR feedback
1 parent a0813ad commit 991fa9d

5 files changed

Lines changed: 20 additions & 19 deletions

File tree

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151
"watch:url": "NODE_ENV=development nodemon bin/cli.js https://hyperparam.blob.core.windows.net/hyperparam/starcoderdata-js-00000-of-00065.parquet"
5252
},
5353
"dependencies": {
54-
"hightable": "0.14.0",
55-
"hyparquet": "1.10.3",
54+
"hightable": "0.14.1",
55+
"hyparquet": "1.10.4",
5656
"hyparquet-compressors": "1.1.1",
57-
"icebird": "0.1.13",
57+
"icebird": "0.1.14",
5858
"react": "18.3.1",
5959
"react-dom": "18.3.1"
6060
},
6161
"devDependencies": {
62-
"@eslint/js": "9.23.0",
62+
"@eslint/js": "9.24.0",
6363
"@storybook/addon-essentials": "8.6.12",
6464
"@storybook/addon-interactions": "8.6.12",
6565
"@storybook/blocks": "8.6.12",
@@ -83,7 +83,7 @@
8383
"npm-run-all": "4.1.5",
8484
"storybook": "8.6.12",
8585
"typescript": "5.8.3",
86-
"typescript-eslint": "8.29.0",
86+
"typescript-eslint": "8.29.1",
8787
"vite": "6.2.5",
8888
"vitest": "3.1.1"
8989
},

src/components/Dropdown/Dropdown.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
transform: rotate(-90deg);
3636
transition: transform 0.1s;
3737
}
38-
.open .dropdownButton::before {
38+
.dropdown:has([aria-expanded="true"]) .dropdownButton::before {
3939
transform: rotate(0deg);
4040
}
4141

@@ -60,7 +60,7 @@
6060
z-index: 20;
6161
}
6262

63-
.open .dropdownContent {
63+
.dropdown:has([aria-expanded="true"]) .dropdownContent {
6464
max-height: 170px;
6565
overflow-y: auto;
6666
}

src/components/Dropdown/Dropdown.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default meta
88
type Story = StoryObj<typeof Dropdown>;
99
export const Default: Story = {
1010
args: {
11+
label: 'Menu',
1112
children: <>
1213
<button>Item 1</button>
1314
<button>Item 2</button>

src/components/Dropdown/Dropdown.test.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ describe('Dropdown Component', () => {
88
const { container: { children: [ div ] }, queryByText } = render(
99
<Dropdown><div>Child 1</div><div>Child 2</div></Dropdown>
1010
)
11-
expect(div?.classList).not.toContain(styles.open)
11+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('false')
1212
expect(queryByText('Child 1')).toBeDefined()
1313
expect(queryByText('Child 2')).toBeDefined()
14-
expect(div?.classList).not.toContain(styles.dropdownLeft)
14+
expect(div?.classList).toContain(styles.dropdownLeft)
1515
})
1616

1717
it('toggles dropdown content on button click', () => {
@@ -23,11 +23,11 @@ describe('Dropdown Component', () => {
2323
fireEvent.click(dropdownButton)
2424

2525
// Check if dropdown content appears
26-
expect(div?.classList).toContain(styles.open)
26+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('true')
2727

2828
// Click again to close
2929
fireEvent.click(dropdownButton)
30-
expect(div?.classList).not.toContain(styles.open)
30+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('false')
3131
})
3232

3333
it('closes dropdown when clicking outside', () => {
@@ -37,11 +37,11 @@ describe('Dropdown Component', () => {
3737

3838
const dropdownButton = getByRole('button')
3939
fireEvent.click(dropdownButton) // open dropdown
40-
expect(div?.classList).toContain(styles.open)
40+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('true')
4141

4242
// Simulate a click outside
4343
fireEvent.mouseDown(document)
44-
expect(div?.classList).not.toContain(styles.open)
44+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('false')
4545
})
4646

4747
it('does not close dropdown when clicking inside', () => {
@@ -51,12 +51,12 @@ describe('Dropdown Component', () => {
5151

5252
const dropdownButton = getByRole('button')
5353
fireEvent.click(dropdownButton) // open dropdown
54-
expect(div?.classList).toContain(styles.open)
54+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('true')
5555

5656
const dropdownContent = getByText('Child 1').parentElement
5757
if (!dropdownContent) throw new Error('Dropdown content not found')
5858
fireEvent.mouseDown(dropdownContent)
59-
expect(div?.classList).toContain(styles.open)
59+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('true')
6060
})
6161

6262
it('closes dropdown on escape key press', () => {
@@ -66,11 +66,11 @@ describe('Dropdown Component', () => {
6666

6767
const dropdownButton = getByRole('button')
6868
fireEvent.click(dropdownButton) // open dropdown
69-
expect(div?.classList).toContain(styles.open)
69+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('true')
7070

7171
// Press escape key
7272
fireEvent.keyDown(document, { key: 'Escape', code: 'Escape' })
73-
expect(div?.classList).not.toContain(styles.open)
73+
expect(div?.children[0]?.getAttribute('aria-expanded')).toBe('false')
7474
})
7575

7676
it('adds dropdownLeft class when align is left', () => {

src/components/Dropdown/Dropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface DropdownProps {
1818
* <button>Item 2</button>
1919
* </Dropdown>
2020
*/
21-
export default function Dropdown({ label, align, className, children }: DropdownProps) {
21+
export default function Dropdown({ label, align = 'left', className, children }: DropdownProps) {
2222
const [isOpen, setIsOpen] = useState(false)
2323
const dropdownRef = useRef<HTMLDivElement>(null)
2424
const menuRef = useRef<HTMLDivElement>(null)
@@ -56,7 +56,7 @@ export default function Dropdown({ label, align, className, children }: Dropdown
5656

5757
return (
5858
<div
59-
className={cn(styles.dropdown, align === 'left' && styles.dropdownLeft, className, isOpen && styles.open)}
59+
className={cn(styles.dropdown, align === 'left' && styles.dropdownLeft, className)}
6060
ref={dropdownRef}>
6161
<button
6262
className={styles.dropdownButton}

0 commit comments

Comments
 (0)