Skip to content

Commit 2a75339

Browse files
committed
chore: change cursor from checkbox to radio button (#13965)
1 parent 74800c2 commit 2a75339

File tree

1 file changed

+57
-58
lines changed
  • airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/CatalogComboBox

1 file changed

+57
-58
lines changed

airbyte-webapp/src/components/connection/ConnectionForm/SyncCatalogTable/components/CatalogComboBox/CatalogComboBox.tsx

+57-58
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Option } from "components/ui/ComboBox";
1313
import { FlexContainer } from "components/ui/Flex";
1414
import { IconProps } from "components/ui/Icon";
1515
import { Input } from "components/ui/Input";
16+
import { RadioButton } from "components/ui/RadioButton";
1617
import { Text } from "components/ui/Text";
1718
import { Tooltip } from "components/ui/Tooltip";
1819

@@ -174,69 +175,67 @@ ControlButton.displayName = "ControlButton";
174175
interface OptionsProps {
175176
options: Array<Option & { disabled?: boolean; disabledReason?: React.ReactNode }>;
176177
filterQuery: string;
178+
multiple?: boolean;
177179
}
178-
const Options = React.forwardRef(({ options, filterQuery }: OptionsProps, ref: React.Ref<HTMLUListElement>) => {
179-
const { formatMessage } = useIntl();
180-
const filteredOptions =
181-
filterQuery === ""
182-
? options
183-
: options.filter((option) => option.value.toLowerCase().includes(filterQuery.toLowerCase()));
180+
const Options = React.forwardRef(
181+
({ options, filterQuery, multiple }: OptionsProps, ref: React.Ref<HTMLUListElement>) => {
182+
const { formatMessage } = useIntl();
183+
const filteredOptions =
184+
filterQuery === ""
185+
? options
186+
: options.filter((option) => option.value.toLowerCase().includes(filterQuery.toLowerCase()));
184187

185-
return (
186-
<ComboboxOptions ref={ref} className={styles.optionsMenu}>
187-
{filteredOptions.length === 0 ? (
188-
<FlexContainer className={styles.optionValue} alignItems="center">
189-
<Text size="md">{formatMessage({ id: "ui.combobox.noOptions" })}</Text>
190-
</FlexContainer>
191-
) : (
192-
filteredOptions.map(({ disabled, disabledReason, value }) => (
193-
<ComboboxOption disabled={disabled} className={styles.option} key={value} value={value}>
194-
{({ focus, selected }) => {
195-
const control = (
196-
<FlexContainer
197-
className={classnames(styles.optionValue, {
198-
[styles.focus]: focus,
199-
[styles.selected]: selected,
200-
})}
201-
alignItems="center"
202-
>
203-
<CheckBox checkboxSize="sm" checked={selected} onClick={(e) => e.preventDefault()} readOnly />
204-
<Text size="md" color={disabled ? "grey" : "darkBlue"}>
205-
<TextHighlighter searchWords={[filterQuery]} textToHighlight={value} />
206-
</Text>
207-
</FlexContainer>
208-
);
209-
return (
210-
<Tooltip
211-
placement="top"
212-
disabled={!(disabled && disabledReason)}
213-
containerClassName={styles.block}
214-
control={control}
215-
>
216-
{disabledReason}
217-
</Tooltip>
218-
);
219-
}}
220-
</ComboboxOption>
221-
))
222-
)}
223-
</ComboboxOptions>
224-
);
225-
});
188+
return (
189+
<ComboboxOptions ref={ref} className={styles.optionsMenu}>
190+
{filteredOptions.length === 0 ? (
191+
<FlexContainer className={styles.optionValue} alignItems="center">
192+
<Text size="md">{formatMessage({ id: "ui.combobox.noOptions" })}</Text>
193+
</FlexContainer>
194+
) : (
195+
filteredOptions.map(({ disabled, disabledReason, value }) => (
196+
<ComboboxOption disabled={disabled} className={styles.option} key={value} value={value}>
197+
{({ focus, selected }) => {
198+
const control = (
199+
<FlexContainer
200+
className={classnames(styles.optionValue, {
201+
[styles.focus]: focus,
202+
[styles.selected]: selected,
203+
})}
204+
alignItems="center"
205+
>
206+
{multiple ? (
207+
<CheckBox checkboxSize="sm" checked={selected} onClick={(e) => e.preventDefault()} readOnly />
208+
) : (
209+
<RadioButton checked={selected} onClick={(e) => e.preventDefault()} readOnly />
210+
)}
211+
<Text size="md" color={disabled ? "grey" : "darkBlue"}>
212+
<TextHighlighter searchWords={[filterQuery]} textToHighlight={value} />
213+
</Text>
214+
</FlexContainer>
215+
);
216+
return (
217+
<Tooltip
218+
placement="top"
219+
disabled={!(disabled && disabledReason)}
220+
containerClassName={styles.block}
221+
control={control}
222+
>
223+
{disabledReason}
224+
</Tooltip>
225+
);
226+
}}
227+
</ComboboxOption>
228+
))
229+
)}
230+
</ComboboxOptions>
231+
);
232+
}
233+
);
226234
Options.displayName = "Options";
227235

228236
export const CatalogComboBox: React.FC<CatalogComboBoxProps> = ({ value, options, onChange, ...restControlProps }) => {
229237
const [filterQuery, setFilterQuery] = useState("");
230238

231-
const onChangeHandler = (newValue: string) => {
232-
// add ability to unselect the option
233-
if (value !== newValue) {
234-
onChange(newValue);
235-
} else {
236-
onChange("");
237-
}
238-
};
239-
240239
const onCloseOptionsMenu = () => {
241240
// reset filter value after closing the options menu
242241
if (filterQuery.length) {
@@ -247,7 +246,7 @@ export const CatalogComboBox: React.FC<CatalogComboBoxProps> = ({ value, options
247246
return (
248247
<Combobox
249248
value={value}
250-
onChange={onChangeHandler}
249+
onChange={onChange}
251250
disabled={restControlProps.disabled}
252251
onClose={onCloseOptionsMenu}
253252
immediate
@@ -303,7 +302,7 @@ export const MultiCatalogComboBox: React.FC<MultiCatalogComboBoxProps> = ({
303302
{({ open }) => (
304303
<FloatLayout>
305304
<ControlButton open={open} value={selectedOptions} setFilterQuery={setFilterQuery} {...restControlProps} />
306-
<Options options={options} filterQuery={filterQuery} />
305+
<Options options={options} filterQuery={filterQuery} multiple />
307306
</FloatLayout>
308307
)}
309308
</Combobox>

0 commit comments

Comments
 (0)