Skip to content

Commit

Permalink
Improve tabindex focus handling for keyboard usage
Browse files Browse the repository at this point in the history
  • Loading branch information
DZunke committed Mar 6, 2019
1 parent f95e768 commit 2b8a0fb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
12 changes: 10 additions & 2 deletions public/assets/js/protocol.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
$(document).ready(function() {

$('input[tabindex=1]').focus();

$('textarea, input[type="text"]').keydown(function (e) {
if (e.ctrlKey && e.keyCode == 13) { // STRG + Enter
$(this).closest('form').submit();
Expand All @@ -10,13 +12,19 @@ $(document).ready(function() {
}
});

$('#focusguard').on('focus', function() {
console.log('FOCUSED');
$('input[tabindex=1]').focus();
});

function reset() {
$('#protocol_parent').val('');
$('#protocol-add-child-info').remove();
$('#protocol-add-child-reset').remove();
$('.protocol-add-child-highlite').removeClass('protocol-add-child-highlite');

$('form').find('input, textarea').val('');
$('input[tabindex=1]').focus();
}

$('.protocol-add-child').on('click', function(e) {
Expand All @@ -34,9 +42,9 @@ $(document).ready(function() {
}

$formElement.parent().prepend('<p id="protocol-add-child-info" class="text-center" data-append="' + $id + '"><strong>Anfügenmodus</strong></p>');
$formElement.parent().append('<button type="button" id="protocol-add-child-reset" class="btn btn-block btn-primary">Abbrechen</button>');
$formElement.parent().append('<button type="button" id="protocol-add-child-reset" class="btn btn-block btn-primary" tabindex="4">Abbrechen</button>');

$('#protocol_sender').focus();
$('input[tabindex=1]').focus();

$('#protocol-add-child-reset').on('click', function(e) {
e.preventDefault();
Expand Down
Empty file removed src/Controller/.gitignore
Empty file.
Empty file removed src/Entity/.gitignore
Empty file.
Empty file removed src/Migrations/.gitignore
Empty file.
Empty file removed src/Repository/.gitignore
Empty file.
5 changes: 5 additions & 0 deletions templates/protocol/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
<button type="submit" class="btn btn-block btn-secondary" tabindex="3">Speichern</button>
</div>
{{ form_end(form) }}
<p class="mt-5">
<strong>STRG + C</strong>: Abbrechen einer Eingabe<br />
<strong>STRG + Return</strong>: Absenden des Formulars
</p>
<span id="focusguard" tabindex="5"></span>
</div>
</div>
</div>
Expand Down
Empty file removed translations/.gitignore
Empty file.

0 comments on commit 2b8a0fb

Please sign in to comment.