Skip to content

Conversation

@Light2Dark
Copy link
Contributor

📝 Summary

Closes #8024. There was a timing issue where the edits are applied even when data is empty, hence they are not applied.

🔍 Description of Changes

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Tests have been added for the changes made.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Pull request title is a good summary of the changes - it will be used in the release notes.

@Light2Dark Light2Dark requested a review from manzt as a code owner January 28, 2026 10:13
@vercel
Copy link

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jan 28, 2026 10:18am

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a timing issue in the data editor where edits were being applied before data had loaded, resulting in edits not being applied at all. The fix changes from using useOnMount to using useEffect with dependencies on data.length and edits, and adds a ref to track whether edits have been applied.

Changes:

  • Replaced useOnMount with useEffect to apply edits only after data has loaded
  • Added hasAppliedEdits ref to prevent re-applying edits on subsequent renders
  • Moved columns definition before the edit-application logic (required for the effect to access it)
  • Removed a TODO comment about old edits

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
frontend/src/plugins/impl/data-editor/glide-data-editor.tsx Replaced useOnMount with useEffect to fix timing issue when applying initial edits, added ref to track application state, and reorganized code
frontend/src/plugins/impl/DataEditorPlugin.tsx Removed TODO comment about old edits

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +131 to +137
// Apply initial edits after data has loaded
useEffect(() => {
// Don't apply if already applied or data hasn't loaded yet
if (hasAppliedEdits.current || data.length === 0) {
return;
}

Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition data.length === 0 prevents the effect from running when data is empty. However, this also prevents processing edits that add new rows to an initially empty dataset (see lines 149-157 which handle edit.rowIdx >= data.length). If a user starts with an empty dataset and has edits that add rows, those edits won't be applied. Consider using a separate loading state flag or checking if data has been initialized, rather than relying solely on data.length.

Suggested change
// Apply initial edits after data has loaded
useEffect(() => {
// Don't apply if already applied or data hasn't loaded yet
if (hasAppliedEdits.current || data.length === 0) {
return;
}
// Apply initial edits once
useEffect(() => {
// Don't apply if:
// - Already applied edits
// - No edits to apply
if (hasAppliedEdits.current || edits.length === 0) {

Copilot uses AI. Check for mistakes.
@Light2Dark Light2Dark added the bug Something isn't working label Jan 28, 2026
@Light2Dark Light2Dark merged commit e437017 into main Jan 28, 2026
32 of 34 checks passed
@Light2Dark Light2Dark deleted the sham/fix-data-editor branch January 28, 2026 18:01
@github-actions
Copy link

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.7-dev31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data_editor integrated within tabs doesn't behave as expected

4 participants