Skip to content

fix: move onReset to run after goToFirst and autoInit (#404) - #408

Open
rickcedwhat-ai wants to merge 2 commits into
mainfrom
fix/404-afterReset
Open

fix: move onReset to run after goToFirst and autoInit (#404)#408
rickcedwhat-ai wants to merge 2 commits into
mainfrom
fix/404-afterReset

Conversation

@rickcedwhat-ai

@rickcedwhat-ai rickcedwhat-ai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Moves onReset to run after goToFirst, cache clear, and autoInit instead of before
  • Previously, DOM settle logic inside onReset fired before the table navigated back to page 1, making the hook ineffective for post-reset waits
  • Updated JSDoc on onReset and reset() to clarify the new timing
  • Added E2E test verifying onReset sees page 1 content

Closes #404

Test plan

  • pnpm exec tsc --noEmit passes
  • All 321 unit tests pass
  • Existing reset() E2E test still passes
  • New onReset runs after goToFirst and autoInit E2E test passes — confirms hook sees page 1

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Reset callbacks now run after the table has returned to page 1, cleared its cache, and reinitialized its headers.
    • Ensures reset callbacks observe the fully restored table state.
  • Documentation

    • Clarified reset behavior and callback timing in the table API documentation.
  • Tests

    • Added coverage confirming reset callbacks run after pagination and automatic initialization complete.

rickcedwhat-ai and others added 2 commits August 6, 2026 00:40
onReset previously ran before pagination reset, so DOM settle logic
inside the hook fired before the table navigated back to page 1.
Move it to the end of reset() so it runs after goToFirst, cache
clear, and autoInit — matching user expectations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rickcedwhat-ai

Copy link
Copy Markdown
Collaborator Author

🤖 Bot HQ

🔗 Issue Link

🔗 Closes #404


🔍 AI Review

  • 🔍 Request AI review

Not yet requested


This comment is managed by the bot — do not edit directly.

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b4423430-4e4a-4780-b177-5aa5802335b1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://rickcedwhat.github.io/playwright-smart-table/pr-preview/pr-408/

Built to branch gh-pages at 2026-08-06 04:41 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/useTable.ts`:
- Line 459: Update reset() in src/useTable.ts: distinguish the
already-first-page case from failed or unsuccessful goToFirst navigation, and
invoke onReset only after page 1 is verified. In src/types.ts at line 918,
document or enforce the resulting page-1 guarantee consistently; regenerate the
corresponding documentation in src/typeContext.ts at line 918 and
docs/.vitepress/tableresult-signatures.json at line 80 to match.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b92dbe42-ebb6-4950-911a-ba73f92a8e0a

📥 Commits

Reviewing files that changed from the base of the PR and between a01cd82 and 535007c.

📒 Files selected for processing (6)
  • docs/.vitepress/tableconfig-signatures.json
  • docs/.vitepress/tableresult-signatures.json
  • src/typeContext.ts
  • src/types.ts
  • src/useTable.ts
  • tests/edge-cases.spec.ts

Comment thread src/useTable.ts
tableMapper.clear();
log("Table reset complete. Calling autoInit to restore state.");
await _autoInit();
await config.onReset(createStrategyContext());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Enforce or qualify the page-1 reset guarantee.

reset() can invoke onReset after an attempted reset while the DOM remains on another page. goToFirst is optional, and its result is not used. The implementation and public documentation must agree.

  • src/useTable.ts#L459-L459: distinguish an already-first-page result from navigation failure, and invoke onReset only after page 1 is verified.
  • src/types.ts#L918-L918: enforce page-1 restoration or document the optional and unsuccessful-navigation fallback.
  • src/typeContext.ts#L918-L918: regenerate this documentation from the corrected source.
  • docs/.vitepress/tableresult-signatures.json#L80-L80: update the generated signature documentation to match the enforced or qualified behavior.
📍 Affects 4 files
  • src/useTable.ts#L459-L459 (this comment)
  • src/types.ts#L918-L918
  • src/typeContext.ts#L918-L918
  • docs/.vitepress/tableresult-signatures.json#L80-L80
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/useTable.ts` at line 459, Update reset() in src/useTable.ts: distinguish
the already-first-page case from failed or unsuccessful goToFirst navigation,
and invoke onReset only after page 1 is verified. In src/types.ts at line 918,
document or enforce the resulting page-1 guarantee consistently; regenerate the
corresponding documentation in src/typeContext.ts at line 918 and
docs/.vitepress/tableresult-signatures.json at line 80 to match.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onReset runs before goToFirst — naming/order is misleading

1 participant