PromucFlow_constructor/app/client/src/components/propertyControls/PrimaryColumnDropdownControl.tsx
Aswath K ca3f159f66
fix: set max-height for Dropdown component (#13105)
* fix: set max-height for Dropdown component

* changes style for date format dropdown

* Combines MultiSelectControl into DropdonwControl

* fix: max height set via props

* fix: popover double scrollbar issue

* fix: styles for chips

* Delete MultiSelectControl

* fix: error when pressing Enter twice

* add tests for multi select & fix some warnings

* removes unwanted test file

* fix: country filtering issue

* address review comments

* fix dropdown for primary columns dropdown

* fix: issue with position

* Adds scrollIntoView when using arrow key for navigation

* fixes issue with scrollbar

* fix: jest tests

* fix: jest test

* fix: flaky cypress test

* fix: height & align issue in Date format selection

* smoothens the scroll
2022-05-06 10:34:17 +05:30

66 lines
1.6 KiB
TypeScript

import React from "react";
import BaseControl, { ControlProps } from "./BaseControl";
import { ColumnProperties } from "widgets/TableWidget/component/Constants";
import { StyledDropDown, StyledDropDownContainer } from "./StyledControls";
import { DropdownOption } from "components/ads/Dropdown";
class PrimaryColumnDropdownControl extends BaseControl<ControlProps> {
render() {
// Get columns from widget properties
const columns: Record<string, ColumnProperties> = this.props
.widgetProperties.primaryColumns;
const options: any[] = [];
for (const i in columns) {
options.push({
label: columns[i].label,
id: columns[i].id,
value: i,
});
}
let defaultSelected: DropdownOption = {
label: "No selection.",
value: undefined,
};
const selected: DropdownOption = options.find(
(option) => option.value === this.props.propertyValue,
);
if (selected) {
defaultSelected = selected;
}
return (
<StyledDropDownContainer>
<StyledDropDown
dropdownMaxHeight="200px"
fillOptions
onSelect={this.onItemSelect}
options={options}
selected={defaultSelected}
showLabelOnly
width="100%"
/>
</StyledDropDownContainer>
);
}
onItemSelect = (value?: string): void => {
if (value) {
this.updateProperty(this.props.propertyName, value);
}
};
static getControlType() {
return "PRIMARY_COLUMNS_DROPDOWN";
}
}
export interface PrimaryColumnDropdownControlProps extends ControlProps {
propertyValue: string;
}
export default PrimaryColumnDropdownControl;