Skip to content

Commit

Permalink
fix: Add isInvalid prop to Select component (#1883)
Browse files Browse the repository at this point in the history
FIxes #1882
  • Loading branch information
vbabich authored Apr 3, 2024
1 parent a03fa07 commit 1803f31
Show file tree
Hide file tree
Showing 95 changed files with 23 additions and 1 deletion.
18 changes: 18 additions & 0 deletions packages/code-studio/src/styleguide/Inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,24 @@ function Inputs(): React.ReactElement {
</Select>
</div>

<div className="form-group">
<Select
onChange={v => {
// no-op
}}
defaultValue="0"
className="custom-select"
isInvalid
>
<Option disabled value="0">
Custom Selection
</Option>
<Option value="1">One</Option>
<Option value="2">Two</Option>
<Option value="3">Three</Option>
</Select>
</div>

<div className="form-group">
<h5>Input with Select</h5>
<div className="input-group">
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useForwardedRef } from '@deephaven/react-hooks';
type baseSelectProps = Omit<React.HTMLProps<HTMLSelectElement>, 'onChange'>;

export type SelectProps = baseSelectProps & {
isInvalid?: boolean;
onChange: (value: string) => void;
'data-testid'?: string;
};
Expand All @@ -20,6 +21,7 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
const {
children,
className,
isInvalid,
onChange,
'data-testid': dataTestId,
...rest
Expand All @@ -37,7 +39,9 @@ const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
return (
<select
ref={ref}
className={classNames('custom-select', className)}
className={classNames('custom-select', className, {
'is-invalid': isInvalid,
})}
onChange={handleChange}
data-testid={dataTestId}
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down
Binary file modified tests/styleguide.spec.ts-snapshots/inputs-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/styleguide.spec.ts-snapshots/inputs-firefox-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/styleguide.spec.ts-snapshots/inputs-webkit-linux.png

0 comments on commit 1803f31

Please sign in to comment.