Skip to content

Commit 6a5fd72

Browse files
committed
fix: make generate button focusable
1 parent 5a47c59 commit 6a5fd72

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/popup/addEditInterface.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,19 @@ 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(
233+
loginObj.generateSecret(passwordLength, symbols)
234+
);
235+
passwordGenerated = true;
236+
}
237+
225238
return {
226239
oncreate: function (vnode) {
227240
let elems = ["div.title", "div.location div.store", "div.contents"];
@@ -495,13 +508,13 @@ function AddEditInterface(settingsModel) {
495508
? helpersUI.highlight(loginObj.fields.secret)
496509
: ""
497510
),
498-
m("div.btn.generate", {
511+
m("div.btn.generate[tabindex=0]", {
499512
title: "Generate password",
500-
onclick: () => {
501-
loginObj.setPassword(
502-
loginObj.generateSecret(passwordLength, symbols)
503-
);
504-
passwordGenerated = true;
513+
onclick: () => generateSecret(loginObj),
514+
onkeydown: (e) => {
515+
if (e.code == "Space") {
516+
generateSecret(loginObj)
517+
}
505518
},
506519
}),
507520
]),

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)