-
Notifications
You must be signed in to change notification settings - Fork 205
Fix for spreadsheet scroll jump on inline row edit #2738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Avoid invalidating the full rows query on inline edits and updated the row locally to preserve pagination and scroll position.
Console (appwrite/console)Project ID: Sites (1)
Tip Roll back Sites deployments instantly by switching between versions |
WalkthroughThe change modifies row update handling in a spreadsheet component by replacing a full invalidation call with selective in-place updating. After a row is updated, the code now uses a Map-based index lookup to locate the row in the paginatedRows array. If found, it updates that specific row directly; if not found, no in-memory update occurs. Event tracking and notification logic remain unchanged. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte (1)
633-639: Consider adding debug logging for skipped updates.When a row is edited but not present in the current paginated view (
rowIndex === undefined), the local update is silently skipped. While this appears intentional and aligns with the PR's goal, adding optional debug logging could aid troubleshooting.🔎 Proposed enhancement with debug logging
const rowIndex = rowIndexMap.get(row.$id); if (rowIndex !== undefined) { paginatedRows.update( rowIndex, row as Models.DefaultRow ); +} else { + // Row not in current page view; backend updated but skipping local UI sync + console.debug(`Row ${row.$id} updated in backend but not in current paginated view`); }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx,svelte}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,js,jsx,svelte}: Import reusable modules from the src/lib directory using the $lib alias
Use minimal comments in code; reserve comments for TODOs or complex logic explanations
Use $lib, $routes, and $themes aliases instead of relative paths for module imports
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
src/routes/**/*.svelte
📄 CodeRabbit inference engine (AGENTS.md)
Use SvelteKit file conventions: +page.svelte for components, +page.ts for data loaders, +layout.svelte for wrappers, +error.svelte for error handling, and dynamic route params in square brackets like [param]
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
**/*.{ts,tsx,js,jsx,svelte,json}
📄 CodeRabbit inference engine (AGENTS.md)
Use 4 spaces for indentation, single quotes, 100 character line width, and no trailing commas per Prettier configuration
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
**/*.svelte
📄 CodeRabbit inference engine (AGENTS.md)
Use Svelte 5 + SvelteKit 2 syntax with TypeScript for component development
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
src/routes/**
📄 CodeRabbit inference engine (AGENTS.md)
Configure dynamic routes using SvelteKit convention with [param] syntax in route directory names
Files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
🧠 Learnings (2)
📚 Learning: 2025-09-25T04:21:57.071Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2373
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:536-552
Timestamp: 2025-09-25T04:21:57.071Z
Learning: In the Appwrite console database suggestions flow, after successfully creating columns via `createColumns()`, the `await invalidate(Dependencies.TABLE)` call causes the view to be destroyed and another view (populated table view) to be rendered, automatically cleaning up component state without needing manual reset.
Applied to files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
📚 Learning: 2025-09-30T07:41:06.679Z
Learnt from: ItzNotABug
Repo: appwrite/console PR: 2425
File: src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte:454-468
Timestamp: 2025-09-30T07:41:06.679Z
Learning: In `src/routes/(console)/project-[region]-[project]/databases/database-[database]/(suggestions)/empty.svelte`, the column suggestions API (console.suggestColumns) has a maximum limit of 7 columns returned, which aligns with the initial placeholder count of 7 in customColumns.
Applied to files:
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte
🔇 Additional comments (2)
src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/spreadsheet.svelte (2)
115-116: LGTM: Efficient O(1) row lookup implementation.The reactive Map provides constant-time lookups for row indices, which is appropriate given that row updates need to quickly locate their position in the paginated view. The Map recalculation on every
$paginatedRows.itemschange is acceptable given the pagination limit keeps the dataset size bounded.
633-639: Effective fix for scroll jump issue.The selective in-place update successfully addresses the scroll jump problem by updating only the affected row in the local store instead of invalidating and refetching all rows. The check
rowIndex !== undefinedcorrectly handles index 0 and gracefully handles cases where the edited row isn't in the current paginated view.However, verify that the
Models.RowtoModels.DefaultRowcast at line 637 is type-safe. The cast is needed becausepaginatedRowsexpectsModels.DefaultRow, but the function parameter is typed asModels.Row. While the same cast pattern appears elsewhere in the codebase (cell/edit.svelte), type compatibility between these types cannot be confirmed without access to the external@appwrite.io/consolepackage definitions.

Avoid invalidating the full rows query on inline edits and updated the row locally to preserve pagination and scroll position.
What does this PR do?
This PR fixes an issue where editing a cell in the spreadsheet caused the view to scroll back to the top.
The root cause was that inline row edits were invalidating the entire rows query, which triggered a re-fetch starting from offset 0. This reset pagination state and caused the spreadsheet to lose its scroll position.
For inline edits, a full data reload isn’t necessary because the row is already updated locally and persisted to the backend. This change avoids invalidating the full rows query for inline edits and instead updates the edited row in the local store.
As a result, pagination and scroll position remain stable after editing a row.
Test Plan
scroll.jump.mp4
Related PRs and Issues
Closes #2689
Have you read the Contributing Guidelines on issues?
Yes, I have read and followed the contributing guidelines.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.