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

FilterBuilder: Fix field menu showing for the last items if there's not enough space in the bottom (T852701) #11606

Merged
merged 1 commit into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions js/ui/filter_builder/filter_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1151,9 +1151,10 @@ const FilterBuilder = Widget.inherit({
position: options.menu.position,
animation: options.menu.animation,
contentTemplate: function(contentElement) {
const $menuContainer = $('<div>');
const $menuContainer = $('<div>').appendTo(contentElement);
that._createComponent($menuContainer, TreeView, options.menu);
return $menuContainer;
// T852701
this.repaint();
},
maxHeight: function() {
return getElementMaxHeightByWindow(options.menu.position.of);
Expand Down
31 changes: 31 additions & 0 deletions testing/functional/model/filterBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Selector } from 'testcafe';
import Widget from './internal/widget';

const CLASS = {
item: 'dx-filterbuilder-item-field',
popupContent: 'dx-popup-content',
treeView: 'dx-treeview'
};

class Field {
element: Selector;
text: Promise<string>;

constructor (element: Selector) {
this.element = element;
this.text = element.textContent;
}
};

export default class FilterBuilder extends Widget {
name: string = 'dxFilterBuilder';

getField(index: number = 0): Field {
const fields = this.element.find(`.${CLASS.item}`);
return new Field(fields.nth(index));
}

getPopupTreeView(): Selector {
return Selector(`.${CLASS.popupContent} .${CLASS.treeView}`)
}
}
21 changes: 21 additions & 0 deletions testing/functional/tests/filterBuilder/filterBuilder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Selector, ClientFunction } from 'testcafe';
import url from '../../helpers/getPageUrl';
import FilterBuilder from '../../model/filterBuilder';

const scrollTo = ClientFunction((x, y) => {
window.scrollTo(x,y);
});

fixture `Filter Builder with scroll`
.page(url(__dirname, './pages/T852701.html'));

test("Field menu should be opened on field click if window scroll exists (T852701)", async t => {
const filterBuilder = new FilterBuilder('#filter-builder');
const lastField = filterBuilder.getField(49);

await scrollTo(0, 10000);
await t.click(lastField.element);

await t.expect(lastField.text).eql('Test 50');
await t.expect(filterBuilder.getPopupTreeView().visible).ok();
});
35 changes: 35 additions & 0 deletions testing/functional/tests/filterBuilder/pages/T852701.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>T852701</title>

<link rel="stylesheet" type="text/css" href="../../../../../artifacts/css/dx.common.css"/>
<link rel="stylesheet" type="text/css" href="../../../../../artifacts/css/dx.light.css"/>

<script type="text/javascript" src="../../../../../artifacts/js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../../artifacts/js/dx.all.debug.js"></script>
</head>
<body>
<div id="filter-builder"></div>
<script>
$(function() {
var filter = [];
var fields = [];

for(var i = 1; i <= 50; i++) {
if(i > 1) {
filter.push("or");
}
var name = "Test" + i;
filter.push([name, "=", "Test"]);
fields.push({ dataField: name })
}

$("#filter-builder").dxFilterBuilder({
fields: fields,
value: filter
});
});
</script>
</body>
</html>