From 3aede04cd433f5f188eddcd6f41cb8afd6262ffe Mon Sep 17 00:00:00 2001 From: alokhyland Date: Fri, 10 Jan 2025 15:45:53 +0530 Subject: [PATCH] review comment changes to add comment for blur --- ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js b/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js index 81ef4cf76..7d675e0a2 100644 --- a/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js +++ b/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js @@ -215,8 +215,11 @@ import { FormatBehavior } from '../nuxeo-format-behavior.js'; if (this.autoValidate) { this.validate(); const typeHeadInput = this.$.typeahead.shadowRoot.querySelector('input'); + // In order for setSelectionRange to function properly, + // it must become focused after the user has finished choosing a value from the list; + // in this instance, the input field becomes focused after the user has chosen the value. typeHeadInput.blur(); - const inputLength = typeHeadInput.value.length; + const inputLength = typeHeadInput && typeHeadInput.value && typeHeadInput.value.length; typeHeadInput.setSelectionRange(inputLength, inputLength); typeHeadInput.focus(); }