Skip to content

Commit

Permalink
fix(select): multiline styles (#1914)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrgarciadev authored Nov 7, 2023
1 parent 0eb9f1e commit 7f6218b
Show file tree
Hide file tree
Showing 7 changed files with 744 additions and 721 deletions.
6 changes: 6 additions & 0 deletions .changeset/unlucky-nails-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@nextui-org/select": patch
"@nextui-org/theme": patch
---

Fix #1910 multiline select fixed, style improved.
6 changes: 3 additions & 3 deletions packages/components/select/src/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function Select<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLSelectE
endContent,
placeholder,
renderValue,
isOutsideLeft,
shouldLabelBeOutside,
disableAnimation,
getBaseProps,
getLabelProps,
Expand Down Expand Up @@ -115,10 +115,10 @@ function Select<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLSelectE
return (
<div {...getBaseProps()}>
<HiddenSelect {...getHiddenSelectProps()} />
{isOutsideLeft ? labelContent : null}
{shouldLabelBeOutside ? labelContent : null}
<div {...getMainWrapperProps()}>
<Component {...getTriggerProps()}>
{!isOutsideLeft ? labelContent : null}
{!shouldLabelBeOutside ? labelContent : null}
<div {...getInnerWrapperProps()}>
{startContent}
<span {...getValueProps()}>
Expand Down
3 changes: 1 addition & 2 deletions packages/components/select/src/use-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export function useSelect<T extends object>(originalProps: UseSelectProps<T>) {
labelPlacement === "outside-left" ||
(labelPlacement === "outside" && (hasPlaceholder || !!originalProps.isMultiline));
const shouldLabelBeInside = labelPlacement === "inside";
const isOutsideLeft = labelPlacement === "outside-left";

const isFilled =
state.isOpen ||
hasPlaceholder ||
Expand Down Expand Up @@ -583,7 +583,6 @@ export function useSelect<T extends object>(originalProps: UseSelectProps<T>) {
hasPlaceholder,
renderValue,
selectionMode,
isOutsideLeft,
disableAnimation,
shouldLabelBeOutside,
shouldLabelBeInside,
Expand Down
4 changes: 3 additions & 1 deletion packages/components/select/stories/select.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,10 @@ export const WithChips = {
variant: "bordered",
selectionMode: "multiple",
isMultiline: true,
labelPlacement: "outside",
classNames: {
trigger: "py-2",
base: "max-w-xs",
trigger: "min-h-unit-12 py-2",
},
renderValue: (items: SelectedItems<User>) => {
return (
Expand Down
8 changes: 8 additions & 0 deletions packages/core/theme/src/components/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,14 @@ const input = tv({
label: "group-data-[has-helper=true]:pt-4",
},
},
// isMultiline & labelPlacement="outside"
{
labelPlacement: "outside",
isMultiline: true,
class: {
label: "pb-1.5",
},
},
// isMultiline & labelPlacement="inside"
{
labelPlacement: "inside",
Expand Down
8 changes: 8 additions & 0 deletions packages/core/theme/src/components/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,14 @@ const select = tv({
base: "data-[has-label=true]:mt-[calc(theme(fontSize.small)_+_12px)]",
},
},
// isMultiline & labelPlacement="outside"
{
labelPlacement: "outside",
isMultiline: true,
class: {
label: "pb-1.5",
},
},
// text truncate labelPlacement=[inside,outside]
{
labelPlacement: ["inside", "outside"],
Expand Down
Loading

2 comments on commit 7f6218b

@vercel
Copy link

@vercel vercel bot commented on 7f6218b Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 7f6218b Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.