Skip to content

Commit 345f1b6

Browse files
authored
Merge pull request #513 from tailwindlabs/develop
Next release
2 parents a8bbd0e + e56dd07 commit 345f1b6

File tree

34 files changed

+478
-287
lines changed

34 files changed

+478
-287
lines changed

CHANGELOG.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased - React]
99

10-
- Nothing yet!
10+
### Added
11+
12+
- Ensure that you can use `Transition.Child` when using implicit Transitions ([#503](https://github.com/tailwindlabs/headlessui/pull/503))
13+
- Add `aria-disabled` on disabled `RadioGroup.Option` components ([#543](https://github.com/tailwindlabs/headlessui/pull/543))
14+
15+
### Fixes
16+
17+
- Improve `disabled` and `tabindex` prop handling ([#512](https://github.com/tailwindlabs/headlessui/pull/512))
18+
- Improve React peer dependency version range ([#544](https://github.com/tailwindlabs/headlessui/pull/544))
19+
- Improve types for the `open` prop in the `Dialog` component ([#550](https://github.com/tailwindlabs/headlessui/pull/550))
20+
- Improve `aria-expanded` logic ([#592](https://github.com/tailwindlabs/headlessui/pull/592))
21+
- Remove undocumented `:className` prop ([#607](https://github.com/tailwindlabs/headlessui/pull/607))
22+
- Improve types for `Listbox` component ([#576](https://github.com/tailwindlabs/headlessui/pull/576))
23+
- Remove explicit `:class` prop ([#608](https://github.com/tailwindlabs/headlessui/pull/608))
24+
- Improve tree shaking ([#602](https://github.com/tailwindlabs/headlessui/pull/602))
25+
- Improve peer dependencies for `react-dom`, and for the future version `18` ([#622](https://github.com/tailwindlabs/headlessui/pull/622))
1126

1227
## [Unreleased - Vue]
1328

14-
- Nothing yet!
29+
### Added
30+
31+
- Ensure that you can use `TransitionChild` when using implicit Transitions ([#503](https://github.com/tailwindlabs/headlessui/pull/503))
32+
- Add `aria-disabled` on disabled `RadioGroup.Option` components ([#543](https://github.com/tailwindlabs/headlessui/pull/543))
33+
34+
### Fixes
35+
36+
- Improve `disabled` and `tabindex` prop handling ([#512](https://github.com/tailwindlabs/headlessui/pull/512))
37+
- Improve reactivity when destructuring from props ([#512](https://github.com/tailwindlabs/headlessui/pull/512))
38+
- Improve `aria-expanded` logic ([#592](https://github.com/tailwindlabs/headlessui/pull/592))
1539

1640
## [@headlessui/react@v1.2.0] - 2021-05-10
1741

packages/@headlessui-react/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"description": "A set of completely unstyled, fully accessible UI components for React, designed to integrate beautifully with Tailwind CSS.",
55
"main": "dist/index.js",
66
"typings": "dist/index.d.ts",
7-
"module": "dist/headlessui.esm.js",
7+
"module": "dist/index.esm.js",
88
"license": "MIT",
99
"files": [
1010
"README.md",
1111
"dist"
1212
],
13+
"sideEffects": false,
1314
"engines": {
1415
"node": ">=10"
1516
},
@@ -30,7 +31,8 @@
3031
"lint": "../../scripts/lint.sh"
3132
},
3233
"peerDependencies": {
33-
"react": ">=16"
34+
"react": "^16 || ^17 || ^18",
35+
"react-dom": "^16 || ^17 || ^18"
3436
},
3537
"devDependencies": {
3638
"@types/react": "^16.14.2",

packages/@headlessui-react/pages/dialog/dialog.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ export default function Home() {
7474
<div className="fixed z-10 inset-0 overflow-y-auto">
7575
<div className="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
7676
<Transition.Child
77+
as={Fragment}
7778
enter="ease-out duration-300"
7879
enterFrom="opacity-0"
79-
enterTo="opacity-100"
80+
enterTo="opacity-75"
8081
leave="ease-in duration-200"
81-
leaveFrom="opacity-100"
82+
leaveFrom="opacity-75"
8283
leaveTo="opacity-0"
84+
entered="opacity-75"
8385
>
84-
<Dialog.Overlay className="fixed inset-0 transition-opacity">
85-
<div className="absolute inset-0 bg-gray-500 opacity-75"></div>
86-
</Dialog.Overlay>
86+
<Dialog.Overlay className="fixed inset-0 bg-gray-500 transition-opacity" />
8787
</Transition.Child>
8888

8989
<Transition.Child

packages/@headlessui-react/src/components/disclosure/disclosure.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
220220
ref: buttonRef,
221221
id: state.buttonId,
222222
type: 'button',
223-
'aria-expanded': state.disclosureState === DisclosureStates.Open ? true : undefined,
223+
'aria-expanded': props.disabled ? undefined : state.disclosureState === DisclosureStates.Open,
224224
'aria-controls': state.linkedPanel ? state.panelId : undefined,
225225
onKeyDown: handleKeyDown,
226226
onKeyUp: handleKeyUp,

packages/@headlessui-react/src/components/listbox/listbox.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
356356
type: 'button',
357357
'aria-haspopup': true,
358358
'aria-controls': state.optionsRef.current?.id,
359-
'aria-expanded': state.listboxState === ListboxStates.Open ? true : undefined,
359+
'aria-expanded': state.disabled ? undefined : state.listboxState === ListboxStates.Open,
360360
'aria-labelledby': labelledby,
361361
disabled: state.disabled,
362362
onKeyDown: handleKeyDown,
@@ -660,9 +660,10 @@ function Option<
660660
let propsWeControl = {
661661
id,
662662
role: 'option',
663-
tabIndex: -1,
663+
tabIndex: disabled === true ? undefined : -1,
664664
'aria-disabled': disabled === true ? true : undefined,
665665
'aria-selected': selected === true ? true : undefined,
666+
disabled: undefined, // Never forward the `disabled` prop
666667
onClick: handleClick,
667668
onFocus: handleFocus,
668669
onPointerMove: handleMove,

packages/@headlessui-react/src/components/menu/menu.test.tsx

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,60 @@ describe('Composition', () => {
496496
])
497497
})
498498
)
499+
500+
it(
501+
'should be possible to wrap the Menu.Items with a Transition.Child component',
502+
suppressConsoleLogs(async () => {
503+
let orderFn = jest.fn()
504+
render(
505+
<Menu>
506+
<Menu.Button>Trigger</Menu.Button>
507+
<Debug name="Menu" fn={orderFn} />
508+
<Transition.Child>
509+
<Debug name="Transition" fn={orderFn} />
510+
<Menu.Items>
511+
<Menu.Item as="a">
512+
{data => (
513+
<>
514+
{JSON.stringify(data)}
515+
<Debug name="Menu.Item" fn={orderFn} />
516+
</>
517+
)}
518+
</Menu.Item>
519+
</Menu.Items>
520+
</Transition.Child>
521+
</Menu>
522+
)
523+
524+
assertMenuButton({
525+
state: MenuState.InvisibleUnmounted,
526+
attributes: { id: 'headlessui-menu-button-1' },
527+
})
528+
assertMenu({ state: MenuState.InvisibleUnmounted })
529+
530+
await click(getMenuButton())
531+
532+
assertMenuButton({
533+
state: MenuState.Visible,
534+
attributes: { id: 'headlessui-menu-button-1' },
535+
})
536+
assertMenu({
537+
state: MenuState.Visible,
538+
textContent: JSON.stringify({ active: false, disabled: false }),
539+
})
540+
541+
await click(getMenuButton())
542+
543+
// Verify that we tracked the `mounts` and `unmounts` in the correct order
544+
expect(orderFn.mock.calls).toEqual([
545+
['Mounting - Menu'],
546+
['Mounting - Transition'],
547+
['Mounting - Menu.Item'],
548+
['Unmounting - Transition'],
549+
['Unmounting - Menu.Item'],
550+
])
551+
})
552+
)
499553
})
500554

501555
describe('Keyboard interactions', () => {

packages/@headlessui-react/src/components/menu/menu.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
297297
type: 'button',
298298
'aria-haspopup': true,
299299
'aria-controls': state.itemsRef.current?.id,
300-
'aria-expanded': state.menuState === MenuStates.Open ? true : undefined,
300+
'aria-expanded': props.disabled ? undefined : state.menuState === MenuStates.Open,
301301
onKeyDown: handleKeyDown,
302302
onKeyUp: handleKeyUp,
303303
onClick: handleClick,
@@ -560,8 +560,9 @@ function Item<TTag extends ElementType = typeof DEFAULT_ITEM_TAG>(
560560
let propsWeControl = {
561561
id,
562562
role: 'menuitem',
563-
tabIndex: -1,
563+
tabIndex: disabled === true ? undefined : -1,
564564
'aria-disabled': disabled === true ? true : undefined,
565+
disabled: undefined, // Never forward the `disabled` prop
565566
onClick: handleClick,
566567
onFocus: handleFocus,
567568
onPointerMove: handleMove,

packages/@headlessui-react/src/components/popover/popover.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ let Button = forwardRefWithAs(function Button<TTag extends ElementType = typeof
440440
ref: buttonRef,
441441
id: state.buttonId,
442442
type: 'button',
443-
'aria-expanded': state.popoverState === PopoverStates.Open ? true : undefined,
443+
'aria-expanded': props.disabled ? undefined : state.popoverState === PopoverStates.Open,
444444
'aria-controls': state.panel ? state.panelId : undefined,
445445
onKeyDown: handleKeyDown,
446446
onKeyUp: handleKeyUp,

packages/@headlessui-react/src/components/radio-group/radio-group.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,11 @@ describe('Rendering', () => {
177177
// Make sure that the onChange handler never got called
178178
expect(changeFn).toHaveBeenCalledTimes(0)
179179

180+
// Make sure that all the options get an `aria-disabled`
181+
let options = getRadioGroupOptions()
182+
expect(options).toHaveLength(4)
183+
for (let option of options) expect(option).toHaveAttribute('aria-disabled', 'true')
184+
180185
// Toggle the disabled state
181186
await click(getByText('Toggle'))
182187

@@ -234,6 +239,17 @@ describe('Rendering', () => {
234239
// Make sure that the onChange handler never got called
235240
expect(changeFn).toHaveBeenCalledTimes(0)
236241

242+
// Make sure that the option with value "render-prop" gets an `aria-disabled`
243+
let options = getRadioGroupOptions()
244+
expect(options).toHaveLength(4)
245+
for (let option of options) {
246+
if (option.dataset.value) {
247+
expect(option).toHaveAttribute('aria-disabled', 'true')
248+
} else {
249+
expect(option).not.toHaveAttribute('aria-disabled')
250+
}
251+
}
252+
237253
// Toggle the disabled state
238254
await click(getByText('Toggle'))
239255

packages/@headlessui-react/src/components/radio-group/radio-group.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ function Option<
352352
'aria-checked': checked ? 'true' : 'false',
353353
'aria-labelledby': labelledby,
354354
'aria-describedby': describedby,
355+
'aria-disabled': isDisabled ? true : undefined,
355356
tabIndex: (() => {
356357
if (isDisabled) return -1
357358
if (checked) return 0

0 commit comments

Comments
 (0)