Skip to content

Commit

Permalink
fix IME input
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Hartmann <[email protected]>
  • Loading branch information
Chartman123 committed Jan 27, 2025
1 parent d087b97 commit 6395e04
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
22 changes: 12 additions & 10 deletions src/components/Questions/AnswerInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
class="question__item__pseudoInput" />
<input
ref="input"
v-model="localAnswer.text"
:aria-label="ariaLabel"
:placeholder="placeholder"
:value="localAnswer.text"
class="question__input"
:class="{ 'question__input--shifted': !isDropdown }"
:maxlength="maxOptionLength"
Expand Down Expand Up @@ -91,23 +91,19 @@ export default {
},

props: {
answer: {
type: Object,
required: true,
},
allowReorder: {
type: Boolean,
default: true,
},
index: {
type: Number,
answer: {
type: Object,
required: true,
},
formId: {
index: {
type: Number,
required: true,
},
maxIndex: {
formId: {
type: Number,
required: true,
},
Expand All @@ -119,6 +115,10 @@ export default {
type: Boolean,
required: true,
},
maxIndex: {
type: Number,
required: true,
},
maxOptionLength: {
type: Number,
required: true,
Expand Down Expand Up @@ -183,8 +183,11 @@ export default {
*/
async handleInput() {
let response

if (this.localAnswer.local) {
this.localAnswer.local = false
response = await this.createAnswer(this.localAnswer)
response.text = this.$refs.input.value
} else {
response = await this.updateAnswer(this.localAnswer)
}
Expand Down Expand Up @@ -244,7 +247,6 @@ export default {
{
id: this.formId,
questionId: answer.questionId,
order: answer.order ?? this.maxIndex,
},
),
{
Expand Down
18 changes: 14 additions & 4 deletions src/mixins/QuestionMultipleMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default defineComponent({
if (this.readOnly && this.extraSettings?.shuffleOptions) {
return this.shuffleArray(this.options)
}

// Ensure order of options always is the same
const options = [...this.options].sort((a, b) => {
if (a.order === b.order) {
Expand Down Expand Up @@ -169,9 +170,14 @@ export default defineComponent({
// let's not await, deleting in background
axios
.delete(
generateOcsUrl('apps/forms/api/v2.4/option/{id}', {
id: option.id,
}),
generateOcsUrl(
'apps/forms/api/v3/forms/{id}/questions/{questionId}/options/{optionId}',
{
id: this.formId,
questionId: this.id,
optionId: option.id,
},
),
)
.catch((error) => {
logger.error('Error while deleting an option', {
Expand Down Expand Up @@ -209,7 +215,11 @@ export default defineComponent({

await axios.patch(
generateOcsUrl(
`apps/forms/api/v2.5/question/${this.id}/options`,
`apps/forms/api/v3/forms/{id}/questions/{questionId}/options`,
{
id: this.formId,
questionId: this.id,
},
),
{
order,
Expand Down

0 comments on commit 6395e04

Please sign in to comment.