From 3161b0df902c8bc3bb53f1f1c0707cae8f25a8a1 Mon Sep 17 00:00:00 2001 From: Olivier Louvignes Date: Wed, 16 Nov 2022 18:02:34 +0100 Subject: [PATCH] Allow custom `id` attribute to `` --- .../src/components/listbox/listbox.test.tsx | 10 ++++++++++ .../src/components/listbox/listbox.tsx | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/@headlessui-react/src/components/listbox/listbox.test.tsx b/packages/@headlessui-react/src/components/listbox/listbox.test.tsx index 84f415d3c9..6180ae3ff1 100644 --- a/packages/@headlessui-react/src/components/listbox/listbox.test.tsx +++ b/packages/@headlessui-react/src/components/listbox/listbox.test.tsx @@ -658,6 +658,16 @@ describe('Rendering', () => { expect(getListboxButton()).not.toHaveAttribute('type') }) + + it('should support a custom `id` attribute', async () => { + render( + + Trigger + + ) + + expect(getListboxButton()).toHaveAttribute('id', 'my-custom-id') + }) }) }) diff --git a/packages/@headlessui-react/src/components/listbox/listbox.tsx b/packages/@headlessui-react/src/components/listbox/listbox.tsx index e7c52bc5a9..15b3e1095a 100644 --- a/packages/@headlessui-react/src/components/listbox/listbox.tsx +++ b/packages/@headlessui-react/src/components/listbox/listbox.tsx @@ -592,7 +592,7 @@ let Button = forwardRefWithAs(function Button) => {