mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-11-18 22:01:36 +08:00
20 lines
327 B
JavaScript
20 lines
327 B
JavaScript
|
/**
|
||
|
* A hook used to focus an element whenever it receives LV update.
|
||
|
*/
|
||
|
const FocusOnUpdate = {
|
||
|
mounted() {
|
||
|
this.__focus();
|
||
|
},
|
||
|
|
||
|
updated() {
|
||
|
this.__focus();
|
||
|
},
|
||
|
|
||
|
__focus() {
|
||
|
this.el.focus();
|
||
|
this.el.selectionStart = this.el.selectionEnd = this.el.value.length;
|
||
|
},
|
||
|
};
|
||
|
|
||
|
export default FocusOnUpdate;
|