Skip to content

Commit 2dc7d12

Browse files
authored
Make generate password button tab focusable (#384)
1 parent 176a418 commit 2dc7d12

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

src/popup/addEditInterface.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,17 @@ function AddEditInterface(settingsModel) {
222222
return `min-width: 65px; max-width: 442px; width: ${length * 8}px;`;
223223
}
224224

225+
/**
226+
* Generate and set a new secret on the provided login object
227+
*
228+
* @param {object} login current secret details
229+
* @returns {void}
230+
*/
231+
function generateSecret(login) {
232+
loginObj.setPassword(loginObj.generateSecret(passwordLength, symbols));
233+
passwordGenerated = true;
234+
}
235+
225236
return {
226237
oncreate: function (vnode) {
227238
let elems = ["div.title", "div.location div.store", "div.contents"];
@@ -490,13 +501,13 @@ function AddEditInterface(settingsModel) {
490501
? helpersUI.highlight(loginObj.fields.secret)
491502
: ""
492503
),
493-
m("div.btn.generate", {
504+
m("div.btn.generate[tabindex=0]", {
494505
title: "Generate password",
495-
onclick: () => {
496-
loginObj.setPassword(
497-
loginObj.generateSecret(passwordLength, symbols)
498-
);
499-
passwordGenerated = true;
506+
onclick: () => generateSecret(loginObj),
507+
onkeydown: (e) => {
508+
if (e.code == "Space") {
509+
generateSecret(loginObj)
510+
}
500511
},
501512
}),
502513
]),

src/popup/colors.less

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@
4747
.addEdit,
4848
.details {
4949
.btn {
50+
&.generate {
51+
background-color: @edit-bg-color;
52+
}
53+
5054
&:hover,
5155
&:focus {
5256
background-color: @hover-bg-color;
5357
}
54-
55-
&.generate {
56-
background-color: @edit-bg-color;
57-
}
5858
}
5959

6060
.contents {

0 commit comments

Comments
 (0)