From 880595be150d318bb68fa7ba374fed7c84a0d03a Mon Sep 17 00:00:00 2001 From: nicholas Date: Mon, 15 Jul 2024 15:37:54 +0200 Subject: [PATCH] Solving issue with having an id on the SelectButtonElement that was breaking Riverty & CtP unit tests --- .../components/Installments/Installments.tsx | 1 + .../components/internal/FormFields/Select/Select.tsx | 4 +++- .../FormFields/Select/components/SelectButton.tsx | 11 +++++++++-- .../components/internal/FormFields/Select/types.ts | 2 ++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/lib/src/components/Card/components/CardInput/components/Installments/Installments.tsx b/packages/lib/src/components/Card/components/CardInput/components/Installments/Installments.tsx index 656c004250..ccca313b67 100644 --- a/packages/lib/src/components/Card/components/CardInput/components/Installments/Installments.tsx +++ b/packages/lib/src/components/Card/components/CardInput/components/Installments/Installments.tsx @@ -133,6 +133,7 @@ function Installments(props: InstallmentsProps) { onChange={onSelectInstallment} name={'installments'} readonly={installmentOptions?.values?.length === 1} + allowIdOnButton={true} /> diff --git a/packages/lib/src/components/internal/FormFields/Select/Select.tsx b/packages/lib/src/components/internal/FormFields/Select/Select.tsx index b59b043c85..1372ef7a74 100644 --- a/packages/lib/src/components/internal/FormFields/Select/Select.tsx +++ b/packages/lib/src/components/internal/FormFields/Select/Select.tsx @@ -29,7 +29,8 @@ function Select({ disableTextFilter, clearOnSelect, blurOnClose, - onListToggle + onListToggle, + allowIdOnButton = false }: SelectProps) { const filterInputRef = useRef(null); const selectContainerRef = useRef(null); @@ -289,6 +290,7 @@ function Select({ toggleList={toggleList} disabled={disabled} ariaDescribedBy={uniqueId ? `${uniqueId}${ARIA_ERROR_SUFFIX}` : null} + allowIdOnButton={allowIdOnButton} /> ; + if (filterable) { + // Even if passed, we can't add an id to this div since it is not allowed to associate a div with a label element + const { id, ...strippedProps } = props; + return
; + } return