Fix inline editing second-edit stale value (#948) - #1297
Open
radimvaculik wants to merge 1 commit into
Open
Conversation
Po úspěšné inline editaci se aktualizuje atribut data-datagrid-editable-value zadanou hodnotou, aby druhá editace vycházela z aktuální hodnoty místo hodnoty z prvotního načtení stránky (issue #948).
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1297 +/- ##
=======================================
Coverage 49.12% 49.12%
=======================================
Files 63 63
Lines 2974 2974
=======================================
Hits 1461 1461
Misses 1513 1513 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
When a column uses
setEditableValueCallback()together with inline editing, the first edit works correctly, but a second edit of the same cell shows the value from before the first edit.Reported in #948.
Root cause
On render, the cell stores the raw editable value in the
data-datagrid-editable-valueattribute, whileinnerHTMLholds the rendered representation. The client readsvalueToEditfrom that attribute.After a successful edit, the client updates only
innerHTML(to_datagrid_editable_new_value), but never updates thedata-datagrid-editable-valueattribute. So the next edit reads the stale value captured on the initial page load.Fix
After a successful inline edit, sync
data-datagrid-editable-valuewith the submitted input value, so subsequent edits start from the current value. Applies to both text/textarea and select inputs.Purely client-side (
assets/plugins/features/editable.ts); no server round-trip needed since the submitted raw value is already available on the client.Closes #948