Skip to content

Commit

Permalink
fix: ComboBoxInput.tsx uses chips only if multiselect (#1029)
Browse files Browse the repository at this point in the history
- Fixes single selects using chips. I missed a check for `isMultiSelect`
- Reverts pagination to original size
  • Loading branch information
apattersonATX-HB authored May 21, 2024
1 parent 4d3fb13 commit 2c32e65
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export function Pagination(props: PaginationProps) {
<div css={Css.df.mya.mr2.$} {...tid.pageSizeLabel}>
Page size:
</div>
<div css={Css.wPx(95).$}>
<div css={Css.wPx(78).$}>
<SelectField
compact
label="Page Size"
Expand Down
7 changes: 3 additions & 4 deletions src/inputs/internal/ComboBoxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ComboBoxState } from "react-stately";
import { Chips, Icon, Tooltip } from "src/components";
import { PresentationFieldProps, usePresentationContext } from "src/components/PresentationContext";
import { Css } from "src/Css";
import { useGrowingTextField } from "src/inputs/hooks/useGrowingTextField";
import { TextFieldBase } from "src/inputs/TextFieldBase";
import { useTreeSelectFieldProvider } from "src/inputs/TreeSelectField/TreeSelectField";
import { isLeveledNode } from "src/inputs/TreeSelectField/utils";
Expand Down Expand Up @@ -85,8 +84,8 @@ export function ComboBoxInput<O, V extends Value>(props: ComboBoxInputProps<O, V
const [isFocused, setIsFocused] = useState(false);
const isMultiSelect = state.selectionManager.selectionMode === "multiple";
const showNumSelection = isMultiSelect && state.selectionManager.selectedKeys.size > 1;
// Show selections as chips
const hasSelection = state.selectionManager.selectedKeys.size > 0;
// Show selections as chips when using multiselect when unfocused
const showChipSelection = isMultiSelect && state.selectionManager.selectedKeys.size > 0;
// For MultiSelect only show the `fieldDecoration` when input is not in focus.
const showFieldDecoration =
(!isMultiSelect || (isMultiSelect && !isFocused)) && fieldDecoration && selectedOptions.length === 1;
Expand All @@ -99,7 +98,7 @@ export function ComboBoxInput<O, V extends Value>(props: ComboBoxInputProps<O, V
<TextFieldBase
{...otherProps}
{...multilineProps}
unfocusedPlaceholder={hasSelection && <Chips compact={otherProps.compact} values={chipLabels} />}
unfocusedPlaceholder={showChipSelection && <Chips compact={otherProps.compact} values={chipLabels} />}
inputRef={inputRef}
inputWrapRef={inputWrapRef}
errorMsg={errorMsg}
Expand Down

0 comments on commit 2c32e65

Please sign in to comment.