Skip to content

Commit 1f6e82f

Browse files
committed
Fix for multiselect with search on grid.
1 parent 1c9ba3e commit 1f6e82f

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminGridSearchSelectAllTest">
11+
<annotations>
12+
<stories value="Selection should be removed during search."/>
13+
<title value="Selection should be removed during search."/>
14+
<description value="Empty selected before and after search, like it works for filter"/>
15+
<testCaseId value=""/>
16+
<severity value="CRITICAL"/>
17+
<group value="uI"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
21+
<!--Create three customers-->
22+
<createData entity="Simple_US_Customer" stepKey="firstCustomer"/>
23+
<createData entity="Simple_US_Customer" stepKey="secondCustomer"/>
24+
<createData entity="Simple_US_Customer" stepKey="thirdCustomer"/>
25+
</before>
26+
<after>
27+
<!--Remove two created customers, third already deleted-->
28+
<deleteData createDataKey="firstCustomer" stepKey="deleteFirstCustomer"/>
29+
<deleteData createDataKey="secondCustomer" stepKey="deleteSecondCustomer"/>
30+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
31+
</after>
32+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="openCustomerPage"/>
33+
<!-- search Admin Data Grid By Keyword -->
34+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFilters"/>
35+
<fillField selector="{{AdminDataGridHeaderSection.search}}" userInput="$$secondCustomer.email$$" stepKey="fillKeywordSearchFieldWithSecondCustomerEmail"/>
36+
<click selector="{{AdminDataGridHeaderSection.submitSearch}}" stepKey="clickKeywordSearch"/>
37+
<waitForPageLoad stepKey="waitForPageLoad"/>
38+
<!-- Check select all action -->
39+
<actionGroup ref="AdminSelectAllCustomers" stepKey="selectAllCustomers"/>
40+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerIsCheckedAfterSelectAll"/>
41+
<!-- Clear searching By Keyword-->
42+
<conditionalClick selector="{{AdminDataGridHeaderSection.clearFilters}}" dependentSelector="{{AdminDataGridHeaderSection.clearFilters}}" visible="true" stepKey="clickClearFiltersAfterSearch"/>
43+
<waitForPageLoad stepKey="waitForPageLoadAfterSearchRemoved"/>
44+
<!-- Check if selection has bee removed -->
45+
<dontSeeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$secondCustomer.email$$)}}" stepKey="checkSecondCustomerCheckboxIsUnchecked"/>
46+
<!-- Check delete action -->
47+
<click selector="{{AdminCustomerGridMainActionsSection.customerCheckbox(($$thirdCustomer.email$$)}}" stepKey="selectThirdCustomer"/>
48+
<seeCheckboxIsChecked selector="{{AdminCustomerGridMainActionsSection.customerCheckbox($$thirdCustomer.email$$)}}" stepKey="checkThirdCustomerIsChecked"/>
49+
<!-- Use delete action for selected -->
50+
<click selector="{{AdminCustomerGridMainActionsSection.actions}}" stepKey="clickActions"/>
51+
<click selector="{{AdminCustomerGridMainActionsSection.delete}}" stepKey="clickDelete"/>
52+
<waitForAjaxLoad stepKey="waitForLoadConfirmation"/>
53+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmDelete"/>
54+
<!-- Check if only one record record has been deleted -->
55+
<see selector="{{AdminMessagesSection.success}}" userInput="A total of 1 record(s) were deleted" stepKey="seeSuccess"/>
56+
</test>
57+
</tests>

app/code/Magento/Ui/view/base/web/js/grid/columns/multiselect.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ define([
5252

5353
listens: {
5454
'${ $.provider }:params.filters': 'onFilter',
55+
'${ $.provider }:params.search': 'onSearch',
5556
selected: 'onSelectedChange',
5657
rows: 'onRowsChange'
5758
},
@@ -235,7 +236,7 @@ define([
235236
* @returns {Multiselect} Chainable.
236237
*/
237238
togglePage: function () {
238-
return this.isPageSelected() ? this.deselectPage() : this.selectPage();
239+
return this.isPageSelected() && !this.excluded().length ? this.deselectPage() : this.selectPage();
239240
},
240241

241242
/**
@@ -496,6 +497,13 @@ define([
496497
if (!this.preserveSelectionsOnFilter) {
497498
this.deselectAll();
498499
}
500+
},
501+
502+
/**
503+
* Is invoked when search is applied or removed
504+
*/
505+
onSearch: function () {
506+
this.onFilter();
499507
}
500508
});
501509
});

0 commit comments

Comments
 (0)