Use a button to show/hide password in the management area

When using a link, people using screen readers might think they're going
to a new page where the password is going to be shown. With a button,
they get a better idea about what to expect.

Furthermore, with a button, we can use the `aria-pressed` attribute to
indicate whether the password is currently being shown.
This commit is contained in:
Javi Martín
2025-02-26 08:57:30 +01:00
parent 5df85bac4e
commit 573f0e62cc
4 changed files with 13 additions and 7 deletions

View File

@@ -60,14 +60,17 @@ describe "Account" do
new_password = find_field("user_password").value
expect(page).to have_field "Password", type: :password
expect(page).to have_css "button[aria-pressed=false]", exact_text: "Show password"
click_link "Show password"
click_button "Show password"
expect(page).to have_field "Password", type: :text
expect(page).to have_css "button[aria-pressed=true]", exact_text: "Show password"
click_link "Show password"
click_button "Show password"
expect(page).to have_field "Password", type: :password
expect(page).to have_css "button[aria-pressed=false]", exact_text: "Show password"
click_button "Save password"