Defect Fix: DataTable Cell Edit Issue with Overlay Components #7874
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.
Related Issues: #7710 #7520
This Pull Request addresses a defect in the PrimeVue DataTable component, specifically when using cell edit mode with overlay-based components such as DatePicker, AutoComplete, and Select. The issue, as reported in #7520 and #7710, manifests as the cell editor prematurely closing when a user interacts with the overlay of these components. This prevents the selected value from being properly saved, leading to a frustrating user experience and data loss.
Proposed Solution
I'm not sure if that's the best solution, but maybe it can help on fixing the issue.
To rectify this behavior, the bindDocumentEditListener method has been enhanced to explicitly account for clicks originating from the overlays of DatePicker, AutoComplete, and Select components. The solution involves modifying the selfClick determination logic to include checks for the specific CSS classes associated with these component overlays.
Changes Made:
The bindDocumentEditListener in node_modules/primevue/datatable/BodyCell.vue has been updated as follows:
Testing
This solution has been tested locally by linking the modified PrimeVue source to a sample application. The tests confirm that:
• Interacting with the DatePicker calendar overlay no longer closes the cell editor.
• Selecting an option from the AutoComplete suggestion list no longer closes the cell editor.
• Choosing an item from the Select dropdown no longer closes the cell editor.
• The selected values from these components are correctly passed to the cell-edit-complete callback.
• The general cell edit functionality for other input types remains unaffected.
While I'm not entirely sure if this is the ideal solution, I hope it can serve as a good starting point to resolve issue #7520 and #7710.
I'm available to collaborate on any further refinements, thanks!