Skip to content

feat(metadata-editor): reset setShouldShowOnlyReviewFields on delete action#4517

Merged
mergify[bot] merged 4 commits intobox:masterfrom
dlasecki-box:reset-setShouldShowOnlyReviewFields-on-delete
Apr 28, 2026
Merged

feat(metadata-editor): reset setShouldShowOnlyReviewFields on delete action#4517
mergify[bot] merged 4 commits intobox:masterfrom
dlasecki-box:reset-setShouldShowOnlyReviewFields-on-delete

Conversation

@dlasecki-box
Copy link
Copy Markdown
Contributor

@dlasecki-box dlasecki-box commented Apr 27, 2026

Reset setShouldShowOnlyReviewFields to false on metadata instance delete to prevent stale review-only field state from persisting after deletion.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where the review-only filter stayed enabled after deleting a metadata instance; the filter now resets when an instance is removed to avoid stale UI state.
  • Tests

    • Added automated test coverage for the metadata deletion confirmation flow to validate the delete modal interactions and ensure the deletion callback is invoked correctly.

@dlasecki-box dlasecki-box requested review from a team as code owners April 27, 2026 17:36
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: da555cd4-5096-49ea-8fc4-863c736ab28c

📥 Commits

Reviewing files that changed from the base of the PR and between 9fbfdab and 5abfd52.

📒 Files selected for processing (1)
  • src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/elements/content-sidebar/tests/MetadataSidebarRedesign.test.tsx

Walkthrough

After deleting a metadata instance, the component now resets the shouldShowOnlyReviewFields UI state to false in addition to clearing editingTemplate. A new test covers the deletion confirmation modal flow with the metadata.deleteConfirmationModalCheckbox.enabled feature flag.

Changes

Cohort / File(s) Summary
State Cleanup on Deletion
src/elements/content-sidebar/MetadataSidebarRedesign.tsx
After successful metadata instance deletion, the component sets shouldShowOnlyReviewFields to false alongside clearing editingTemplate.
Deletion Flow Test
src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx
Adds a test for deletion with metadata.deleteConfirmationModalCheckbox.enabled: provides a real handleDeleteMetadataInstance mock and a single instance, opens the delete confirmation modal, clicks the modal-scoped Delete button via within, and asserts the handler was called with the expected instance.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

ready-to-merge

Suggested reviewers

  • Lindar90
  • tjuanitas
  • jpan-box

Poem

🐰 A little hop, a gentle nudge and done,
I clear the filters, let the UI run.
Delete confirmed, the sidebar sings—
Fresh state, fresh view, and happy springs! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: resetting setShouldShowOnlyReviewFields state on metadata deletion.
Description check ✅ Passed The description adequately explains the fix: resetting setShouldShowOnlyReviewFields to prevent stale review-only state after deletion.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`:
- Around line 357-386: The test currently clicks a generic Edit button which is
ambiguous when multiple metadata cards render; update the interaction to scope
the query to the specific card for mockCustomTemplateInstance (e.g., locate the
card element by text from mockCustomTemplateInstance such as its template title
or a unique field key and then use within(card).getByRole('button', { name:
/^Edit\s*$/ }) to click Edit and similarly scope the subsequent Delete click),
ensuring the call to handleDeleteMetadataInstance(mockCustomTemplateInstance)
targets the intended instance.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a89e7a2a-6776-4931-85c5-ffb7eb647e2e

📥 Commits

Reviewing files that changed from the base of the PR and between 6e544f2 and cb18a86.

📒 Files selected for processing (2)
  • src/elements/content-sidebar/MetadataSidebarRedesign.tsx
  • src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx (1)

378-380: ⚠️ Potential issue | 🟡 Minor

Target the intended metadata instance explicitly.

Using generic 'Edit' / 'Delete' selectors is ambiguous with multiple cards and can hit the wrong instance. Use an instance-specific accessible name (or scope with within on the intended card) before triggering delete.

Suggested test hardening
-        await userEvent.click(screen.getByRole('button', { name: 'Edit' }));
-        await userEvent.click(screen.getByRole('button', { name: 'Delete' }));
+        await userEvent.click(screen.getByRole('button', { name: 'Edit Custom Metadata' }));
+        await userEvent.click(screen.getByRole('button', { name: 'Delete' }));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`
around lines 378 - 380, The test is clicking generic buttons which is ambiguous
when multiple metadata cards exist; update the clicks to target the specific
metadata instance by first locating the intended card element (e.g., find the
card by its unique text or title) and then scope the queries using
within(card).getByRole('button', { name: 'Edit' }) and
within(card).getByRole('button', { name: 'Delete' }) (or use instance-specific
accessible names like "Edit metadata for <name>" / "Delete metadata for <name>")
before calling userEvent.click so the correct card's edit/delete buttons are
activated.
🧹 Nitpick comments (1)
src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx (1)

385-385: Tighten the delete callback assertion.

Also assert call count so this test fails on duplicate/unexpected invocations.

Suggested assertion update
-        expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance);
+        expect(handleDeleteMetadataInstance).toHaveBeenCalledTimes(1);
+        expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx` at
line 385, Update the test to assert the exact number of times the delete
callback was invoked in addition to its argument: add an assertion that
handleDeleteMetadataInstance was called exactly once (e.g.,
expect(handleDeleteMetadataInstance).toHaveBeenCalledTimes(1)) and then keep the
existing
expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance)
to ensure no duplicate or unexpected invocations occur; locate the assertions
around handleDeleteMetadataInstance in MetadataSidebarRedesign.test.tsx and
place the toHaveBeenCalledTimes(1) check immediately before or after the
existing toHaveBeenCalledWith check.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`:
- Around line 378-380: The test is clicking generic buttons which is ambiguous
when multiple metadata cards exist; update the clicks to target the specific
metadata instance by first locating the intended card element (e.g., find the
card by its unique text or title) and then scope the queries using
within(card).getByRole('button', { name: 'Edit' }) and
within(card).getByRole('button', { name: 'Delete' }) (or use instance-specific
accessible names like "Edit metadata for <name>" / "Delete metadata for <name>")
before calling userEvent.click so the correct card's edit/delete buttons are
activated.

---

Nitpick comments:
In `@src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx`:
- Line 385: Update the test to assert the exact number of times the delete
callback was invoked in addition to its argument: add an assertion that
handleDeleteMetadataInstance was called exactly once (e.g.,
expect(handleDeleteMetadataInstance).toHaveBeenCalledTimes(1)) and then keep the
existing
expect(handleDeleteMetadataInstance).toHaveBeenCalledWith(mockCustomTemplateInstance)
to ensure no duplicate or unexpected invocations occur; locate the assertions
around handleDeleteMetadataInstance in MetadataSidebarRedesign.test.tsx and
place the toHaveBeenCalledTimes(1) check immediately before or after the
existing toHaveBeenCalledWith check.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc296573-9b8c-4f21-a76c-79e54a3e7908

📥 Commits

Reviewing files that changed from the base of the PR and between cb18a86 and 9fbfdab.

📒 Files selected for processing (1)
  • src/elements/content-sidebar/__tests__/MetadataSidebarRedesign.test.tsx

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Apr 28, 2026

Merge Queue Status

  • Entered queue2026-04-28 14:57 UTC · Rule: Automatic strict merge
  • Checks passed · in-place
  • Merged2026-04-28 15:08 UTC · at 936b489941b5c382a7830f926d0dd810707194b9 · squash

This pull request spent 11 minutes 10 seconds in the queue, including 10 minutes 45 seconds running CI.

Required conditions to merge

@mergify mergify Bot merged commit 6420743 into box:master Apr 28, 2026
8 of 9 checks passed
@mergify mergify Bot removed the queued label Apr 28, 2026
kduncanhsu pushed a commit to kduncanhsu/box-ui-elements that referenced this pull request Apr 28, 2026
…action (box#4517)

* feat(metadata-editor): reset setShouldShowOnlyReviewFields on delete action

* feat(metadata-editor): simplify test selector

* feat(metadata-editor): update mocks

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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.

4 participants