-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FilterBuilder: Fix field menu showing for the last items if there's n…
…ot enough space in the bottom (T852701) (#11606)
- Loading branch information
Showing
4 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |