fix: select widget search improvement (#17006)
* fix: type issues in select widget * feat: add cypress tests * fix: select type issues in JSONform and Table Widget Co-authored-by: souma-ghosh <souma@appsmith.com> Co-authored-by: Pawan Kumar <pawan.stardust@gmail.com>
This commit is contained in:
parent
d2de8f7cec
commit
589f2b9765
|
|
@ -234,4 +234,45 @@ describe("Select Widget Functionality", function() {
|
||||||
);
|
);
|
||||||
cy.goToEditFromPublish();
|
cy.goToEditFromPublish();
|
||||||
});
|
});
|
||||||
|
it("should check that filtering works well using numeric labels", () => {
|
||||||
|
cy.openPropertyPane("selectwidget");
|
||||||
|
cy.updateCodeInput(
|
||||||
|
".t--property-control-options",
|
||||||
|
`[
|
||||||
|
{
|
||||||
|
"label": 1,
|
||||||
|
"value": "BLUE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": 2,
|
||||||
|
"value": "GREEN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "3",
|
||||||
|
"value": "RED"
|
||||||
|
}
|
||||||
|
]`,
|
||||||
|
);
|
||||||
|
cy.dragAndDropToCanvas("textwidget", { x: 300, y: 80 });
|
||||||
|
cy.openPropertyPane("textwidget");
|
||||||
|
cy.testJsontext("text", "{{typeof Select1.selectedOptionLabel}}");
|
||||||
|
// Filtering the option
|
||||||
|
cy.get(formWidgetsPage.selectWidget)
|
||||||
|
.find(widgetsPage.dropdownSingleSelect)
|
||||||
|
.click({
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
cy.get(commonlocators.selectInputSearch).type("1");
|
||||||
|
// confirm it only has a single child
|
||||||
|
cy.get(".select-popover-wrapper .menu-virtual-list")
|
||||||
|
.children()
|
||||||
|
.should("have.length", 1);
|
||||||
|
cy.get(commonlocators.singleSelectWidgetMenuItem).contains("1");
|
||||||
|
cy.get(commonlocators.singleSelectWidgetMenuItem).click({
|
||||||
|
force: true,
|
||||||
|
});
|
||||||
|
cy.get(commonlocators.TextInside)
|
||||||
|
.first()
|
||||||
|
.should("have.text", "number");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ function SelectField({
|
||||||
placeholder={schemaItem.placeholderText}
|
placeholder={schemaItem.placeholderText}
|
||||||
selectedIndex={selectedIndex}
|
selectedIndex={selectedIndex}
|
||||||
serverSideFiltering={schemaItem.serverSideFiltering}
|
serverSideFiltering={schemaItem.serverSideFiltering}
|
||||||
value={options[selectedOptionIndex]?.value}
|
value={options[selectedOptionIndex]?.value?.toString()}
|
||||||
widgetId={fieldClassName}
|
widgetId={fieldClassName}
|
||||||
width={10}
|
width={10}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,10 @@ class SelectComponent extends React.Component<
|
||||||
|
|
||||||
const filter = items.filter(
|
const filter = items.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
item.label?.toLowerCase().includes(query.toLowerCase()) ||
|
item.label
|
||||||
|
?.toString()
|
||||||
|
.toLowerCase()
|
||||||
|
.includes(query.toLowerCase()) ||
|
||||||
String(item.value)
|
String(item.value)
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.includes(query.toLowerCase()),
|
.includes(query.toLowerCase()),
|
||||||
|
|
@ -296,7 +299,7 @@ class SelectComponent extends React.Component<
|
||||||
this.spanRef.current.parentElement.scrollHeight ||
|
this.spanRef.current.parentElement.scrollHeight ||
|
||||||
this.spanRef.current.parentElement.offsetWidth <
|
this.spanRef.current.parentElement.offsetWidth <
|
||||||
this.spanRef.current.parentElement.scrollWidth)
|
this.spanRef.current.parentElement.scrollWidth)
|
||||||
? value
|
? value.toString()
|
||||||
: "";
|
: "";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -387,13 +390,13 @@ class SelectComponent extends React.Component<
|
||||||
>
|
>
|
||||||
<SelectButton
|
<SelectButton
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
displayText={value}
|
displayText={value.toString()}
|
||||||
handleCancelClick={this.handleCancelClick}
|
handleCancelClick={this.handleCancelClick}
|
||||||
hideCancelIcon={this.props.hideCancelIcon}
|
hideCancelIcon={this.props.hideCancelIcon}
|
||||||
spanRef={this.spanRef}
|
spanRef={this.spanRef}
|
||||||
togglePopoverVisibility={this.togglePopoverVisibility}
|
togglePopoverVisibility={this.togglePopoverVisibility}
|
||||||
tooltipText={tooltipText}
|
tooltipText={tooltipText}
|
||||||
value={this.props.value}
|
value={this.props.value?.toString()}
|
||||||
/>
|
/>
|
||||||
</StyledSingleDropDown>
|
</StyledSingleDropDown>
|
||||||
</StyledControlGroup>
|
</StyledControlGroup>
|
||||||
|
|
@ -426,8 +429,8 @@ export interface SelectComponentProps extends ComponentProps {
|
||||||
serverSideFiltering: boolean;
|
serverSideFiltering: boolean;
|
||||||
hasError?: boolean;
|
hasError?: boolean;
|
||||||
onFilterChange: (text: string) => void;
|
onFilterChange: (text: string) => void;
|
||||||
value?: string;
|
value?: string | number;
|
||||||
label?: string;
|
label?: string | number;
|
||||||
filterText?: string;
|
filterText?: string;
|
||||||
borderRadius: string;
|
borderRadius: string;
|
||||||
boxShadow?: string;
|
boxShadow?: string;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
import { Intent as BlueprintIntent } from "@blueprintjs/core";
|
import { Intent as BlueprintIntent } from "@blueprintjs/core";
|
||||||
import { IconName } from "@blueprintjs/icons";
|
import { IconName } from "@blueprintjs/icons";
|
||||||
|
|
||||||
export type SelectionType = "SINGLE_SELECT" | "MULTI_SELECT";
|
|
||||||
export interface DropdownOption {
|
export interface DropdownOption {
|
||||||
label?: string;
|
label?: string | number;
|
||||||
value?: string;
|
value?: string | number;
|
||||||
icon?: IconName;
|
icon?: IconName;
|
||||||
subText?: string;
|
subText?: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ type SelectProps = {
|
||||||
action?: string,
|
action?: string,
|
||||||
) => void;
|
) => void;
|
||||||
onItemSelect: (
|
onItemSelect: (
|
||||||
value: string,
|
value: string | number,
|
||||||
rowIndex: number,
|
rowIndex: number,
|
||||||
column: string,
|
column: string,
|
||||||
action?: string,
|
action?: string,
|
||||||
|
|
|
||||||
|
|
@ -1841,7 +1841,7 @@ class TableWidgetV2 extends BaseWidget<TableWidgetProps, WidgetState> {
|
||||||
};
|
};
|
||||||
|
|
||||||
onOptionSelect = (
|
onOptionSelect = (
|
||||||
value: string,
|
value: string | number,
|
||||||
rowIndex: number,
|
rowIndex: number,
|
||||||
column: string,
|
column: string,
|
||||||
action?: string,
|
action?: string,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user