Skip to content

Commit

Permalink
fix(components): fix Button detection of Select context
Browse files Browse the repository at this point in the history
  • Loading branch information
Niznikr committed Oct 22, 2024
1 parent 3764368 commit 8f1b560
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-ways-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@launchpad-ui/components": patch
---

Fix `Button` detection of `Select` context
8 changes: 5 additions & 3 deletions packages/components/src/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import type { ForwardedRef } from 'react';
import type { ButtonProps as AriaButtonProps } from 'react-aria-components';

import { cva, cx } from 'class-variance-authority';
import { forwardRef } from 'react';
import { forwardRef, useContext } from 'react';
import {
Button as AriaButton,
Provider,
SelectContext,
SelectStateContext,
TextContext,
composeRenderProps,
useSlottedContext,
Expand Down Expand Up @@ -45,13 +46,14 @@ const _Button = (
ref: ForwardedRef<HTMLButtonElement>,
) => {
const selectContext = useSlottedContext(SelectContext);
const state = useContext(SelectStateContext);
return (
<AriaButton
{...props}
ref={ref}
className={composeRenderProps(props.className, (className, renderProps) =>
selectContext
? cx(input(), styles.select, selectContext.isInvalid && styles.invalid, className)
state
? cx(input(), styles.select, selectContext?.isInvalid && styles.invalid, className)
: button({ ...renderProps, size, variant, className }),
)}
>
Expand Down

0 comments on commit 8f1b560

Please sign in to comment.