Keep grid filters when adding a partially deselected selection (#38582) - #41122
Open
lbajsarowicz wants to merge 1 commit into
Open
Keep grid filters when adding a partially deselected selection (#38582)#41122lbajsarowicz wants to merge 1 commit into
lbajsarowicz wants to merge 1 commit into
Conversation
…to#38582) Insert-listing's updateFromServerData() cleared the applied grid filters unconditionally. In exclude mode the request is constrained only by a 'nin' condition on the excluded ids, so dropping the filters made the modal request the entire collection (with paging.notLimits = 1) instead of the filtered subset. On large catalogs this froze the product form when adding related, up-sell or cross-sell products after deselecting a few filtered rows. Filters are now preserved in exclude mode and still reset in include mode, where the explicit 'in' list fully constrains the result. Fixes magento#38582
|
Hi @lbajsarowicz. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
Contributor
Author
|
@magento run all tests |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description (*)
When a grid is embedded in a form through
insertListing(Related Products, Up-Sells and Cross-Sells being the most visible case), selecting rows and then deselecting a few of them switches the selections provider into exclude mode: the selection is expressed as "everything matching the current filters, except these ids".Magento\Ui\view\base\web\js\form\components\insert-listing.js::updateFromServerData()builds the request for the selected rows and, whenever there is a non-empty id list, clears the filtering state that was just imported from the grid:In include mode this is harmless — the explicit
inlist fully constrains the result. In exclude mode the only remaining constraint isninon the handful of excluded ids, so together withpaging.notLimits = 1the modal requests the entire product collection minus the excluded ids instead of the filtered subset. On a catalog with thousands of products the response is huge, the grid never finishes rendering and the product form appears to hang.This also explains the two workarounds reported in the issue: adding all filtered rows without deselecting any keeps
excludedempty so the branch is never entered, and raising the page limit so that every selected row is present on the current page makescanUpdateFromClientData()returntrue, skipping the server request entirely.The fix keeps the applied filters in exclude mode and leaves include-mode behaviour untouched.
Fixed Issues (if relevant)
Manual testing scenarios (*)
setup/performance-toolkit/profiles/ce/medium.xml).Expected result: only the remaining filtered products are added and the form stays responsive.
Actual result before the fix: the request returns the whole catalog minus the deselected ids and the product edit page hangs.
The same scenario applies to Up-Sells and Cross-Sells, and to any other
insertListing-based modal.Questions or comments
Automated coverage is added in
dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/form/components/insert-listing.test.js, asserting that the request payload keeps the grid filters in exclude mode and still resets them in include mode. Verified that the new exclude-mode expectation fails against the unpatched component.Contribution checklist (*)