Skip to content

feat(password-update): hide fields behind Set/Change button#82

Merged
tomusdrw merged 1 commit intomainfrom
td-password-toggle
Apr 20, 2026
Merged

feat(password-update): hide fields behind Set/Change button#82
tomusdrw merged 1 commit intomainfrom
td-password-toggle

Conversation

@tomusdrw
Copy link
Copy Markdown
Member

Summary

  • Password inputs in PasswordUpdate are hidden initially; a Set/Change password button reveals the form.
  • Added a Cancel button that collapses the form and clears the fields/error state.
  • On a successful update the form auto-collapses; the success Alert remains visible.

Test plan

  • npx vitest run lib/supabase/PasswordUpdate.test.tsx — 4/4 passing
  • npm run lint — clean
  • npx tsc --noEmit — clean
  • Manual check in Storybook / demo: fields hidden on load; reveal, cancel, and successful submit all behave as expected

🤖 Generated with Claude Code

Password inputs are hidden until the user clicks "Set/Change password".
A Cancel button collapses the form and clears the fields; successful
updates also auto-collapse. Reduces visual noise on the Settings page
when the user isn't actively changing their password.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 20, 2026

Deploy Preview for fluffy-ui ready!

Name Link
🔨 Latest commit 745cf01
🔍 Latest deploy log https://app.netlify.com/projects/fluffy-ui/deploys/69e6880386f0eb00082b0a5b
😎 Deploy Preview https://deploy-preview-82--fluffy-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

The PasswordUpdate component has been modified to hide the password form by default, displaying only a "Set/Change password" toggle button. Clicking it reveals the form with a new cancel button that collapses the form and clears input fields. Tests have been updated to verify this behavior.

Changes

Cohort / File(s) Summary
PasswordUpdate Component
lib/supabase/PasswordUpdate.tsx
Added isEditing state to control form visibility. Form is now hidden by default and shown only after clicking "Set/Change password" button. Introduced handleCancel() to reset form state and toggle editing mode. Updated form submission to return to non-editing state after success.
PasswordUpdate Tests
lib/supabase/PasswordUpdate.test.tsx
Updated logged-in UI test to assert form is initially hidden. Added assertions confirming password input placeholders are absent before toggle. Updated all button queries to use exact-label matching. Added new test verifying cancel button collapses form and clears input fields.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title directly describes the main feature: hiding password fields behind a Set/Change button toggle, which matches the core change in both modified files.
Description check ✅ Passed The description is closely related to the changeset, detailing the three key behavioral changes: hidden fields with a toggle button, cancel functionality, and auto-collapse on success.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch td-password-toggle

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

Copy link
Copy Markdown

@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.

🧹 Nitpick comments (2)
lib/supabase/PasswordUpdate.test.tsx (1)

53-72: Add one test for success-path collapse + success alert persistence.

The PR objective includes “auto-collapse on successful update while success alert remains visible,” but this behavior is not asserted in the updated test set.

Suggested additional test
+  it("collapses the form after successful submit and keeps success alert visible", async () => {
+    const user = userEvent.setup();
+    render(
+      <MockSupabaseProvider user={{ email: "test@example.com" }}>
+        <PasswordUpdate />
+      </MockSupabaseProvider>,
+    );
+
+    await user.click(screen.getByRole("button", { name: /set\/change password/i }));
+    await user.type(screen.getByPlaceholderText("New password"), "newpass123");
+    await user.type(screen.getByPlaceholderText("Confirm new password"), "newpass123");
+    await user.click(screen.getByRole("button", { name: /^set password$/i }));
+
+    expect(screen.queryByPlaceholderText("New password")).not.toBeInTheDocument();
+    expect(screen.queryByPlaceholderText("Confirm new password")).not.toBeInTheDocument();
+    expect(screen.getByText(/password updated successfully\./i)).toBeInTheDocument();
+  });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/supabase/PasswordUpdate.test.tsx` around lines 53 - 72, Add a test that
verifies the success-path: render <PasswordUpdate /> inside
<MockSupabaseProvider /> with the Supabase password-update call mocked to
succeed, fill and submit the form using userEvent (like in the existing "Cancel
collapses..." test), then assert the form fields are no longer in the document
(component collapsed) while a visible success alert/message from PasswordUpdate
remains present; use the same helpers (userEvent.setup, screen.getByRole,
screen.getByPlaceholderText, screen.queryByPlaceholderText) and mock the update
call (or provider prop) to return a successful response so the test exercises
auto-collapse on success and persistence of the success alert.
lib/supabase/PasswordUpdate.tsx (1)

76-77: Consider clearing stale success when re-entering edit mode.

On Line 76, re-opening the form can keep a prior success alert visible while editing. Clearing success on edit-start avoids mixed states.

Optional tweak
-        <Button type="button" variant="secondary" onClick={() => setIsEditing(true)}>
+        <Button
+          type="button"
+          variant="secondary"
+          onClick={() => {
+            setSuccess(false);
+            setIsEditing(true);
+          }}
+        >
           Set/Change password
         </Button>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/supabase/PasswordUpdate.tsx` around lines 76 - 77, The Set/Change
password button currently only calls setIsEditing(true) which can leave a prior
success message shown; update the Button onClick handler in PasswordUpdate.tsx
to also clear the success state (call the component's setSuccess(...) with the
empty/neutral value used in this file) when entering edit mode so stale success
alerts are removed; reference the Button element and the state setters
setIsEditing and setSuccess when making this change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@lib/supabase/PasswordUpdate.test.tsx`:
- Around line 53-72: Add a test that verifies the success-path: render
<PasswordUpdate /> inside <MockSupabaseProvider /> with the Supabase
password-update call mocked to succeed, fill and submit the form using userEvent
(like in the existing "Cancel collapses..." test), then assert the form fields
are no longer in the document (component collapsed) while a visible success
alert/message from PasswordUpdate remains present; use the same helpers
(userEvent.setup, screen.getByRole, screen.getByPlaceholderText,
screen.queryByPlaceholderText) and mock the update call (or provider prop) to
return a successful response so the test exercises auto-collapse on success and
persistence of the success alert.

In `@lib/supabase/PasswordUpdate.tsx`:
- Around line 76-77: The Set/Change password button currently only calls
setIsEditing(true) which can leave a prior success message shown; update the
Button onClick handler in PasswordUpdate.tsx to also clear the success state
(call the component's setSuccess(...) with the empty/neutral value used in this
file) when entering edit mode so stale success alerts are removed; reference the
Button element and the state setters setIsEditing and setSuccess when making
this change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09d0fc11-b19b-47b2-b8c5-3a6e1f1d8994

📥 Commits

Reviewing files that changed from the base of the PR and between ebc7aa0 and 745cf01.

📒 Files selected for processing (2)
  • lib/supabase/PasswordUpdate.test.tsx
  • lib/supabase/PasswordUpdate.tsx

@tomusdrw tomusdrw merged commit 036818f into main Apr 20, 2026
6 checks passed
@tomusdrw tomusdrw deleted the td-password-toggle branch April 20, 2026 20:30
@github-actions github-actions Bot mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant