DS Picker: Support width and hideTextValue (#70074)

This commit is contained in:
Ivan Ortega Alba 2023-06-15 16:34:20 +02:00 committed by GitHub
parent f323a6151c
commit 5b97670f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -31,7 +31,7 @@ const INTERACTION_ITEM = {
};
export function DataSourceDropdown(props: DataSourceDropdownProps) {
const { current, onChange, ...restProps } = props;
const { current, onChange, hideTextValue, width, ...restProps } = props;
const [isOpen, setOpen] = useState(false);
const [inputHasFocus, setInputHasFocus] = useState(false);
@ -107,7 +107,7 @@ export function DataSourceDropdown(props: DataSourceDropdownProps) {
const styles = useStyles2(getStylesDropdown);
return (
<div className={styles.container} data-testid={selectors.components.DataSourcePicker.container}>
<div className={styles.container} data-testid={selectors.components.DataSourcePicker.container} style={{ width }}>
{/* This clickable div is just extending the clickable area on the input element to include the prefix and suffix. */}
{/* eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions */}
<div className={styles.trigger} onClick={openDropdown}>
@ -122,7 +122,7 @@ export function DataSourceDropdown(props: DataSourceDropdownProps) {
)
}
suffix={<Icon name={isOpen ? 'search' : 'angle-down'} />}
placeholder={dataSourceLabel(currentDataSourceInstanceSettings)}
placeholder={hideTextValue ? '' : dataSourceLabel(currentDataSourceInstanceSettings)}
onClick={openDropdown}
onFocus={() => {
setInputHasFocus(true);

View File

@ -12,6 +12,8 @@ export interface DataSourceDropdownProps {
fileUploadOptions?: DropzoneOptions;
onClickAddCSV?: () => void;
recentlyUsed?: string[];
hideTextValue?: boolean;
width?: number;
}
export interface PickerContentProps extends DataSourceDropdownProps {