Skip to content

Commit

Permalink
Popup has wrong height after list search (#6168)
Browse files Browse the repository at this point in the history
* resolve #6167 Popup has wrong height after list search

* work for #6167 : fix f-test

---------

Co-authored-by: OlgaLarina <olga.larina.dev@gmail.com>
  • Loading branch information
OlgaLarina and OlgaLarina committed May 12, 2023
1 parent 3f0012d commit c02d037
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class PopupModel<T = any> extends Base {
public onFooterActionsCreated: EventBase<Base> = this.addEvent<Base>();
public onRecalculatePosition: EventBase<Base> = this.addEvent<Base>();

private refreshInnerModel(): void {
const innerModel = (this.contentComponentData as any)["model"];
innerModel && innerModel.refresh && innerModel.refresh();
}

constructor(
contentComponentName: string,
contentComponentData: T,
Expand Down Expand Up @@ -87,9 +92,8 @@ export class PopupModel<T = any> extends Base {
}
this.setPropertyValue("isVisible", value);
this.onVisibilityChanged.fire(this, { model: this, isVisible: value });
this.refreshInnerModel();
if (this.isVisible) {
const innerModel = (this.contentComponentData as any)["model"];
innerModel && innerModel.refresh && innerModel.refresh();
this.onShow();
} else {
this.onHide();
Expand Down
52 changes: 52 additions & 0 deletions testCafe/components/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,56 @@ frameworks.forEach(async framework => {
.expect(popupSelector.visible).ok()
.expect(popupSelector.offsetHeight).eql(346);
});
test("check popup with filter", async t => {
const currentAddDropdownTitleAction = (_, opt) => {
if(opt.question.name !== "actions_question") return;

let items: Array<any> = [];
for (let index = 0; index < 20; index++) {
items[index] = new window["Survey"].Action({ title: "item" + index });
}
const item = window["Survey"].createDropdownActionModel(
{ title: "Click", showTitle: true },
{ items: items }
);
opt.titleActions = [item];
};
const insertContainer = ClientFunction(() => {
const container = document.createElement("div");
container.style.height = "200px";
const surveyEl = document.getElementById("surveyElement");
surveyEl?.parentElement?.insertBefore(container, document.getElementById("surveyElement"));
});

await insertContainer();
await initSurvey(framework, {
elements: [
{
type: "text",
name: "q1"
},
{
type: "text",
name: "q2"
},
{
type: "text",
name: "actions_question"
}
]
}, { onGetQuestionTitleActions: currentAddDropdownTitleAction });

const popupHeight = 455;
await t
.click(clickButton)
.expect(popupSelector.visible).ok()
.expect(popupSelector.offsetHeight).within(popupHeight - 1, popupHeight + 1)
.typeText(Selector(".sv-list__input"), "2")
.expect(popupSelector.offsetHeight).within(popupHeight - 1, popupHeight + 1)
.click(clickButton)
.expect(popupSelector.visible).notOk()
.click(clickButton)
.expect(popupSelector.visible).ok()
.expect(popupSelector.offsetHeight).within(popupHeight - 1, popupHeight + 1);
});
});

0 comments on commit c02d037

Please sign in to comment.