Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make suggestions tapable/clickable #765

Merged
merged 2 commits into from Oct 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 10 additions & 7 deletions internal/view/assets/js/component/dialog.js
Expand Up @@ -31,9 +31,10 @@ var template = `
@focus="$event.target.select()"
@keyup="handleInput(index)"
@keyup.enter="handleInputEnter(index)">
<span :ref="'suggestion-'+index"
v-if="field.suggestion"
class="suggestion">{{field.suggestion}}</span>
<button :ref="'suggestion-'+index"
v-if="field.suggestion"
@click="handleInputEnter(index)"
class="suggestion">{{field.suggestion}}</button>
</template>
</slot>
</div>
Expand Down Expand Up @@ -191,11 +192,11 @@ export default {
// Display suggestion
this.$nextTick(() => {
var input = this.$refs.input[index],
span = this.$refs['suggestion-' + index][0],
suggestionNode = this.$refs['suggestion-' + index][0],
inputRect = input.getBoundingClientRect();

span.style.top = (inputRect.bottom - 1) + 'px';
span.style.left = inputRect.left + 'px';
suggestionNode.style.top = (inputRect.bottom - 1) + 'px';
suggestionNode.style.left = inputRect.left + 'px';
});
},
handleInputEnter(index) {
Expand All @@ -214,6 +215,8 @@ export default {

this.formFields[index].value = words.join(separator) + separator;
this.formFields[index].suggestion = undefined;
// Focus input again after suggestion is accepted
this.$refs.input[index].focus();
},
focus() {
this.$nextTick(() => {
Expand All @@ -235,4 +238,4 @@ export default {
})
}
}
}
}