Fix focus issues in access and share modals

This commit is contained in:
yflory 2024-06-25 14:19:53 +02:00
parent 8fab5a3d3c
commit 1902305986
3 changed files with 17 additions and 14 deletions

View File

@ -555,12 +555,12 @@ define([
let addTabListener = frame => { let addTabListener = frame => {
// find focusable elements // find focusable elements
let modalElements = $(frame).find('a, button, input, [tabindex]:not([tabindex="-1"]), textarea').filter(':visible'); let modalElements = $(frame).find('a, button, input, [tabindex]:not([tabindex="-1"]), textarea').filter(':visible').filter(':not(:disabled)');
// intialize with focus on first element // intialize with focus on first element
modalElements[0].focus(); modalElements[0].focus();
$(frame).on('keydown', function (e) { $(frame).on('keydown', function (e) {
modalElements = $(frame).find('a, button, input, [tabindex]:not([tabindex="-1"]), textarea').filter(':visible'); // for modals with dynamic content modalElements = $(frame).find('a, button, input, [tabindex]:not([tabindex="-1"]), textarea').filter(':visible').filter(':not(:disabled)'); // for modals with dynamic content
if (e.which === 9) { // Tab if (e.which === 9) { // Tab
if (e.shiftKey) { if (e.shiftKey) {
@ -931,12 +931,14 @@ define([
opts = opts || {}; opts = opts || {};
var attributes = merge({ var attributes = merge({
type: 'password', type: 'password',
tabindex: '1', tabindex: '0',
autocomplete: 'one-time-code', // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values autocomplete: 'one-time-code', // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values
}, opts); }, opts);
var input = h('input.cp-password-input', attributes); var input = h('input.cp-password-input', attributes);
var eye = h('span.fa.fa-eye.cp-password-reveal'); var eye = h('span.fa.fa-eye.cp-password-reveal', {
tabindex: 0
});
var $eye = $(eye); var $eye = $(eye);
var $input = $(input); var $input = $(input);
@ -953,7 +955,8 @@ define([
$input.focus(); $input.focus();
}); });
} else { } else {
$eye.click(function () { Util.onClickEnter($eye, function (e) {
e.stopPropagation();
if ($eye.hasClass('fa-eye')) { if ($eye.hasClass('fa-eye')) {
$input.prop('type', 'text'); $input.prop('type', 'text');
$input.focus(); $input.focus();

View File

@ -188,7 +188,7 @@ define([
'data-curve': data.curvePublic || '', 'data-curve': data.curvePublic || '',
'data-name': name.toLowerCase(), 'data-name': name.toLowerCase(),
'data-order': i, 'data-order': i,
'tabindex': '0', 'tabindex': config.noSelect ? '-1' : '0',
style: 'order:'+i+';' style: 'order:'+i+';'
},[ },[
avatar, avatar,

View File

@ -385,13 +385,13 @@ define([
h('label', Messages.sharedFolders_share), h('label', Messages.sharedFolders_share),
h('br'), h('br'),
] : [ ] : [
UI.createCheckbox('cp-share-embed', Messages.share_linkEmbed, false, { mark: {tabindex:1} }), UI.createCheckbox('cp-share-embed', Messages.share_linkEmbed, false, { mark: {tabindex:0} }),
]; ];
if (opts.static) { linkContent = []; } if (opts.static) { linkContent = []; }
linkContent.push(h('div.cp-spacer')); linkContent.push(h('div.cp-spacer'));
linkContent.push(UI.dialog.selectableArea('', { id: 'cp-share-link-preview', tabindex: 1, rows:3})); linkContent.push(UI.dialog.selectableArea('', { id: 'cp-share-link-preview', tabindex: 0, rows:3}));
// Show alert if the pad is password protected // Show alert if the pad is password protected
if (opts.hasPassword) { if (opts.hasPassword) {
@ -553,7 +553,7 @@ define([
var embedContent = [ var embedContent = [
h('p', Messages.viewEmbedTag), h('p', Messages.viewEmbedTag),
UI.dialog.selectableArea(opts.getEmbedValue(), { id: 'cp-embed-link-preview', tabindex: 1, rows: 3}) UI.dialog.selectableArea(opts.getEmbedValue(), { id: 'cp-embed-link-preview', tabindex: 0, rows: 3})
]; ];
// Show alert if the pad is password protected // Show alert if the pad is password protected
@ -611,24 +611,24 @@ define([
labelEdit = Messages.share_formEdit; labelEdit = Messages.share_formEdit;
labelView = Messages.share_formView; labelView = Messages.share_formView;
auditor = UI.createRadio('accessRights', 'cp-share-form', Messages.share_formAuditor, false, { auditor = UI.createRadio('accessRights', 'cp-share-form', Messages.share_formAuditor, false, {
mark: {tabindex:1}, mark: {tabindex:0},
}); });
} }
var burnAfterReading = (hashes.viewHash && canBAR) ? var burnAfterReading = (hashes.viewHash && canBAR) ?
UI.createRadio('accessRights', 'cp-share-bar', Messages.burnAfterReading_linkBurnAfterReading, false, { UI.createRadio('accessRights', 'cp-share-bar', Messages.burnAfterReading_linkBurnAfterReading, false, {
mark: {tabindex:1}, mark: {tabindex:0},
label: {style: "display: none;"} label: {style: "display: none;"}
}) : undefined; }) : undefined;
var rights = h('div.msg.cp-inline-radio-group', [ var rights = h('div.msg.cp-inline-radio-group', [
h('label',{ for: 'cp-share-editable-true' }, Messages.share_linkAccess), h('label',{ for: 'cp-share-editable-true' }, Messages.share_linkAccess),
h('div.radio-group',[ h('div.radio-group',[
UI.createRadio('accessRights', 'cp-share-editable-false', UI.createRadio('accessRights', 'cp-share-editable-false',
labelView, true, { mark: {tabindex:1} }), labelView, true, { mark: {tabindex:0} }),
canPresent ? UI.createRadio('accessRights', 'cp-share-present', canPresent ? UI.createRadio('accessRights', 'cp-share-present',
Messages.share_linkPresent, false, { mark: {tabindex:1} }) : undefined, Messages.share_linkPresent, false, { mark: {tabindex:1} }) : undefined,
UI.createRadio('accessRights', 'cp-share-editable-true', UI.createRadio('accessRights', 'cp-share-editable-true',
labelEdit, false, { mark: {tabindex:1} }), labelEdit, false, { mark: {tabindex:0} }),
auditor]), auditor]),
burnAfterReading, burnAfterReading,
]); ]);
@ -921,7 +921,7 @@ define([
var cb = Util.once(Util.mkAsync(_cb)); var cb = Util.once(Util.mkAsync(_cb));
var linkContent = [ var linkContent = [
UI.dialog.selectableArea(opts.getLinkValue(), { UI.dialog.selectableArea(opts.getLinkValue(), {
id: 'cp-share-link-preview', tabindex: 1, rows:2 id: 'cp-share-link-preview', tabindex: 0, rows:2
}) })
]; ];