fix(widget-plugin-grid): Clear Selection action wins over Keep selection [WC-3461]#2349
Draft
iobuhov wants to merge 1 commit into
Draft
fix(widget-plugin-grid): Clear Selection action wins over Keep selection [WC-3461]#2349iobuhov wants to merge 1 commit into
iobuhov wants to merge 1 commit into
Conversation
…ext reconciliation Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Why
The Clear Selection JavaScript action (used by Data Grid 2 and Gallery) did not clear the selection when the widget's Keep selection property was enabled — keep selection always won.
createSelectionHelperinstalled an unconditionalsetKeepSelection(() => true)predicate, which the Mendix runtime re-evaluates on every datasource reconciliation, so the clear'ssetSelection([])was undone on the next reconciliation.Ticket: WC-3461
What changed
Scope:
packages/shared/widget-plugin-gridonly. Both widgets inherit the fix through the sharedcreateSelectionHelper— no per-widget source changes.keepActiveobservable read live:setKeepSelection(() => keepActive.get()), installed via thesetup()lifecycle instead of eagerly.MultiSelectionHelper.clearSelection,SingleSelectionHelper.remove),beforeClear()snapshots the currentselectionref, dropskeepActivetofalse(so the runtime does not restore during the clear's reconciliation), then re-arms viawhen(() => selectionValue !== clearedRef, () => keepActive.set(true)).whenself-disposes after firing, is disposed on re-entrant/double clears, and is cancelled on teardown.widget-plugin-test-utilsbuilders capture the predicate so the keep-vs-clear interaction is testable.Testing
widget-plugin-grid: 18 suites / 146 tests pass, including new keep-vs-clear cases (clear-beats-keep,keep-resumes-after-clear,rearm-on-reselect,double-clear-reentrancy,clear-without-keep,dispose-mid-clear, predicate-installed-via-setup).datagrid-web/gallery-web: all selection-touching suites pass. Remaining failing suites fail identically on cleanmain(pre-existing dual-mendix-version type conflict in test helpers, unrelated to this change).Still open (why this is a draft)
Clear_SelectionJS action with Keep selection enabled in a real widget and confirm the selection clears and keep resumes on the next page change. The approach assumes the runtime evaluates the keep predicate during reconciliation (before delivering the new ref that re-arms) — an ordering not provable from unit tests.🤖 Generated with Claude Code