Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:Ensure alert message triggers only once when onDropdownClose in select widget #34812

Open
wants to merge 9 commits into
base: release
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
agHelper,
draggableWidgets,
deployMode,
entityExplorer,
locators,
propPane,
} from "../../../../../support/Objects/ObjectsCore";

describe(
"Select widget tests",
PrasadMadine marked this conversation as resolved.
Show resolved Hide resolved
{ tags: ["@tag.Widget", "@tag.Select"] },
function () {
before(() => {
entityExplorer.DragDropWidgetNVerify(draggableWidgets.SELECT);
});


it("Validate OnDropdownClose events are rendering show alert only once", () => {
propPane.EnterJSContext(
PrasadMadine marked this conversation as resolved.
Show resolved Hide resolved
"onDropdownClose",
"{{showAlert('Dropdown closed!','success')}}",
true,
);
propPane.ToggleJSMode("onDropdownClose", false);
deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.SELECT));
agHelper.GetNClick(locators._widgetInDeployed(draggableWidgets.SELECT));
agHelper.AssertElementVisibility(
locators._selectOptionValue("Red"),
true,
);
agHelper.GetNClick(locators._selectOptionValue("Red"));
agHelper.ValidateToastMessage("Dropdown closed!");
PrasadMadine marked this conversation as resolved.
Show resolved Hide resolved
});
},
);

2 changes: 1 addition & 1 deletion app/client/src/widgets/SelectWidget/component/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class SelectComponent extends React.Component<
};
handleCloseList = () => {
if (this.state.isOpen) {
this.togglePopoverVisibility();
// this.togglePopoverVisibility();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Instead of putting a comment, lets remove this line completely.
  2. For my curiosity, please explain, how this line was causing the alert to come twice? How is it showing that alert once now(which line)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot from 2024-07-05 09-45-34
Screenshot from 2024-07-05 09-44-50

Here in handleCloseList, if isOpen is true togglePopoverVisibility is calling so in togglePopoverVisibility, again it is checking isOpen, so that’s why it is calling two times.

if (!this.props.selectedIndex) return;
return this.handleActiveItemChange(
this.props.options[this.props.selectedIndex],
Expand Down