-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fuselage):
SelectAria
id prop overwriting (#1533)
Co-authored-by: Douglas Fabris <[email protected]>
- Loading branch information
1 parent
c7478d2
commit a5bc3a6
Showing
3 changed files
with
78 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rocket.chat/fuselage': patch | ||
--- | ||
|
||
fix(fuselage): SelectAria id prop overwriting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { AllHTMLAttributes, RefObject } from 'react'; | ||
import { forwardRef } from 'react'; | ||
import { useButton, AriaButtonProps } from 'react-aria'; | ||
|
||
import Box from '../Box'; | ||
|
||
type SelectTriggerProps = { | ||
small?: boolean; | ||
error?: string; | ||
focus?: boolean; | ||
} & AriaButtonProps & | ||
AllHTMLAttributes<HTMLButtonElement>; | ||
|
||
export const SelectTrigger = forwardRef<HTMLButtonElement, SelectTriggerProps>( | ||
({ small, error, isDisabled, focus, id, ...props }, ref) => { | ||
const { buttonProps } = useButton( | ||
props, | ||
ref as RefObject<HTMLButtonElement | null>, | ||
); | ||
|
||
return ( | ||
<Box | ||
{...buttonProps} | ||
id={id} | ||
rcx-select | ||
ref={ref} | ||
is='button' | ||
display='flex' | ||
flexDirection='row' | ||
fontScale='p2' | ||
justifyContent='space-between' | ||
rcx-input-box--small={small} | ||
className={[ | ||
error && 'invalid', | ||
isDisabled && 'disabled', | ||
focus && 'focus', | ||
] | ||
.filter(Boolean) | ||
.join(' ')} | ||
> | ||
{props.children} | ||
</Box> | ||
); | ||
}, | ||
); |