diff --git a/packages/@headlessui-react/src/components/label/label.tsx b/packages/@headlessui-react/src/components/label/label.tsx index d5a7cf9..0d23754 100644 --- a/packages/@headlessui-react/src/components/label/label.tsx +++ b/packages/@headlessui-react/src/components/label/label.tsx @@ -82,10 +82,10 @@ type LabelPropsWeControl = 'id' export function Label( props: Props & { - clickable?: boolean + passive?: boolean } ) { - let { clickable = false, ...passThroughProps } = props + let { passive = false, ...passThroughProps } = props let context = useLabelContext() let id = `headlessui-label-${useId()}` @@ -96,7 +96,7 @@ export function Label( let allProps = { ...passThroughProps, ...propsWeControl } // @ts-expect-error props are dynamic via context, some components will // provide an onClick then we can delete it. - if (!clickable) delete allProps['onClick'] + if (passive) delete allProps['onClick'] return render({ props: allProps, diff --git a/packages/@headlessui-react/src/components/switch/README.md b/packages/@headlessui-react/src/components/switch/README.md index 2020232..bb35a24 100644 --- a/packages/@headlessui-react/src/components/switch/README.md +++ b/packages/@headlessui-react/src/components/switch/README.md @@ -121,10 +121,10 @@ function NotificationsToggle() { ##### Props -| Prop | Type | Default | Description | -| :---------- | :------------------ | :------ | :---------------------------------------------------------------- | -| `as` | String \| Component | `label` | The element or component the `Switch.Label` should render as. | -| `clickable` | Boolean | `false` | Wether or not to toggle the `Switch` when you click on the label. | +| Prop | Type | Default | Description | +| :-------- | :------------------ | :------ | :----------------------------------------------------------------------------------- | +| `as` | String \| Component | `label` | The element or component the `Switch.Label` should render as. | +| `passive` | Boolean | `false` | When `passive` is `false`, clicking the `Switch.Label` will not toggle the `Switch`. | #### Switch.Description diff --git a/packages/@headlessui-react/src/components/switch/switch.test.tsx b/packages/@headlessui-react/src/components/switch/switch.test.tsx index 76fa215..28d350d 100644 --- a/packages/@headlessui-react/src/components/switch/switch.test.tsx +++ b/packages/@headlessui-react/src/components/switch/switch.test.tsx @@ -263,7 +263,7 @@ describe('Mouse interactions', () => { assertSwitch({ state: SwitchState.Off }) }) - it('should be possible to toggle the Switch with a click on the Label (clickable passed)', async () => { + it('should be possible to toggle the Switch with a click on the Label', async () => { let handleChange = jest.fn() function Example() { let [state, setState] = useState(false) @@ -276,7 +276,7 @@ describe('Mouse interactions', () => { handleChange(value) }} /> - The label + The label ) } @@ -305,7 +305,7 @@ describe('Mouse interactions', () => { assertSwitch({ state: SwitchState.Off }) }) - it('should not be possible to toggle the Switch with a click on the Label', async () => { + it('should not be possible to toggle the Switch with a click on the Label (passive)', async () => { let handleChange = jest.fn() function Example() { let [state, setState] = useState(false) @@ -318,7 +318,7 @@ describe('Mouse interactions', () => { handleChange(value) }} /> - The label + The label ) } diff --git a/packages/@headlessui-vue/src/components/label/label.ts b/packages/@headlessui-vue/src/components/label/label.ts index bde54c2..77b9bd7 100644 --- a/packages/@headlessui-vue/src/components/label/label.ts +++ b/packages/@headlessui-vue/src/components/label/label.ts @@ -67,11 +67,11 @@ export let Label = defineComponent({ name: 'Label', props: { as: { type: [Object, String], default: 'label' }, - clickable: { type: [Boolean], default: false }, + passive: { type: [Boolean], default: false }, }, render() { let { name = 'Label', slot = {}, props = {} } = this.context - let { clickable, ...passThroughProps } = this.$props + let { passive, ...passThroughProps } = this.$props let propsWeControl = { ...Object.entries(props).reduce( (acc, [key, value]) => Object.assign(acc, { [key]: unref(value) }), @@ -83,7 +83,7 @@ export let Label = defineComponent({ // @ts-expect-error props are dynamic via context, some components will // provide an onClick then we can delete it. - if (!clickable) delete allProps['onClick'] + if (passive) delete allProps['onClick'] return render({ props: allProps, diff --git a/packages/@headlessui-vue/src/components/switch/README.md b/packages/@headlessui-vue/src/components/switch/README.md index dff35e5..ab01ec4 100644 --- a/packages/@headlessui-vue/src/components/switch/README.md +++ b/packages/@headlessui-vue/src/components/switch/README.md @@ -147,10 +147,10 @@ export default { ##### Props -| Prop | Type | Default | Description | -| :---------- | :------------------ | :------ | :---------------------------------------------------------------- | -| `as` | String \| Component | `label` | The element or component the `SwitchLabel` should render as. | -| `clickable` | Boolean | `false` | Wether or not to toggle the `Switch` when you click on the label. | +| Prop | Type | Default | Description | +| :-------- | :------------------ | :------ | :---------------------------------------------------------------------------------- | +| `as` | String \| Component | `label` | The element or component the `SwitchLabel` should render as. | +| `passive` | Boolean | `false` | When `passive` is `false`, clicking the `SwitchLabel` will not toggle the `Switch`. | #### SwitchDescription diff --git a/packages/@headlessui-vue/src/components/switch/switch.test.tsx b/packages/@headlessui-vue/src/components/switch/switch.test.tsx index c7198ad..6c15b77 100644 --- a/packages/@headlessui-vue/src/components/switch/switch.test.tsx +++ b/packages/@headlessui-vue/src/components/switch/switch.test.tsx @@ -399,13 +399,13 @@ describe('Mouse interactions', () => { assertSwitch({ state: SwitchState.Off }) }) - it('should be possible to toggle the Switch with a click on the Label (clickable passed)', async () => { + it('should be possible to toggle the Switch with a click on the Label', async () => { let handleChange = jest.fn() renderTemplate({ template: html` - The label + The label `, setup() { @@ -437,13 +437,13 @@ describe('Mouse interactions', () => { assertSwitch({ state: SwitchState.Off }) }) - it('should not be possible to toggle the Switch with a click on the Label', async () => { + it('should not be possible to toggle the Switch with a click on the Label (passive)', async () => { let handleChange = jest.fn() renderTemplate({ template: html` - The label + The label `, setup() {