diff --git a/package-lock.json b/package-lock.json index 982fdd8..e579762 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11689,6 +11689,11 @@ "integrity": "sha1-WPcc7jvVGbWdSyqEO2x95krAR2Q=", "dev": true }, + "tabbable": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-4.0.0.tgz", + "integrity": "sha512-H1XoH1URcBOa/rZZWxLxHCtOdVUEev+9vo5YdYhC9tCY4wnybX+VQrCYuy9ubkg69fCBxCONJOSLGfw0DWMffQ==" + }, "table": { "version": "5.4.6", "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz", diff --git a/package.json b/package.json index 41b0911..be92e28 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "v-clipboard": "^2.2.3", "vue": "^2.6.11", "vue-router": "^3.3.4", - "vuedraggable": "^2.23.2" + "vuedraggable": "^2.23.2", + "tabbable": "^4.0.0" }, "browserslist": [ "extends @nextcloud/browserslist-config" diff --git a/src/components/Questions/AnswerInput.vue b/src/components/Questions/AnswerInput.vue index d9aacb3..8485748 100644 --- a/src/components/Questions/AnswerInput.vue +++ b/src/components/Questions/AnswerInput.vue @@ -15,7 +15,7 @@ @keydown.enter.prevent="addNewEntry"> - + {{ t('forms', 'Delete answer') }} @@ -79,6 +79,11 @@ export default { this.$refs.input.focus() }, + onActionsTab(event) { + console.debug('keydownTab') + // this.$emit('focus-next', event.target) + }, + /** * Option changed, processing the data */ diff --git a/src/components/Questions/Question.vue b/src/components/Questions/Question.vue index cb64cbc..6d51754 100644 --- a/src/components/Questions/Question.vue +++ b/src/components/Questions/Question.vue @@ -25,9 +25,7 @@ :class="{ 'question--edit': edit }" :aria-label="t('forms', 'Question number {index}', {index})" class="question" - @click="enableEdit" - @focusin="onFocusIn" - @focusout="onFocusOut"> + @click="enableEdit">
+ @input="onTitleChange" + @keydown.shift.tab.prevent="onTitleShiftTab">

- + {{ t('forms', 'Required') }} @@ -168,6 +170,16 @@ export default { }, methods: { + onTitleShiftTab(event) { + console.debug('this', event.target) + this.$emit('focus-prev', event.target) + this.disableEdit() + }, + onActionsTab(event) { + console.debug('actionsTab', event) + this.$emit('focus-next', event.target) + }, + onTitleChange({ target }) { this.$emit('update:text', target.value) }, @@ -188,26 +200,11 @@ export default { } }, - /** - * Enable & disable resp. edit, if focus jumps to next question (e.g. by tab-navigation) - * @param {Object} event The triggered focusIn/focusOut event - */ - onFocusIn(event) { - if (event.target.closest('.question') !== event.relatedTarget?.closest('.question')) { - this.enableEdit() - } - }, - - onFocusOut(event) { - if (event.target.closest('.question') !== event.relatedTarget?.closest('.question')) { - this.disableEdit() - } - }, - /** * Enable the edit mode */ enableEdit() { + console.debug('enableEdit') if (!this.readOnly) { this.$emit('update:edit', true) } @@ -217,6 +214,7 @@ export default { * Disable the edit mode */ disableEdit() { + console.debug('disableEdit') if (!this.readOnly) { this.$emit('update:edit', false) } diff --git a/src/components/Questions/QuestionLong.vue b/src/components/Questions/QuestionLong.vue index 29c89f2..ca60023 100644 --- a/src/components/Questions/QuestionLong.vue +++ b/src/components/Questions/QuestionLong.vue @@ -32,7 +32,9 @@ :warning-invalid="answerType.warningInvalid" @update:text="onTitleChange" @update:mandatory="onMandatoryChange" - @delete="onDelete"> + @delete="onDelete" + @focus-prev="onFocusPrev" + @focus-next="FocusNextOutside">