Skip to content

Commit

Permalink
fix(plugins/plugin-client-common): input cursor will move to the end …
Browse files Browse the repository at this point in the history
…after tab-completes
  • Loading branch information
myan9 authored and k8s-ci-robot committed May 26, 2021
1 parent 0c240ef commit 671a20f
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,12 @@ class TabCompletionInitialState extends TabCompletionState {
*
*/
function setPromptValue(prompt: HTMLInputElement, newValue: string, selectionStart: number) {
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set
nativeInputValueSetter.call(prompt, newValue)

prompt.selectionStart = selectionStart
prompt.selectionEnd = selectionStart

const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set
nativeInputValueSetter.call(prompt, newValue)
setTimeout(() => prompt.dispatchEvent(new Event('change', { bubbles: true })))
}

Expand Down

0 comments on commit 671a20f

Please sign in to comment.