MCPcopy
hub / github.com/ajaxorg/ace / focus

Method focus

src/keyboard/textinput.js:778–815  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

776 }
777
778 focus() {
779 // On focusing on the textarea, read active row number to assistive tech.
780 this.setAriaOptions({
781 setLabel: this.host.renderer.enableKeyboardAccessibility
782 });
783
784 if (this.tempStyle || HAS_FOCUS_ARGS || this.$focusScroll == "browser") return this.text.focus(
785 {preventScroll: true});
786
787 var top = this.text.style.top;
788 this.text.style.position = "fixed";
789 this.text.style.top = "0px";
790 try {
791 var isTransformed = this.text.getBoundingClientRect().top != 0;
792 } catch (e) {
793 // getBoundingClientRect on IE throws error if element is not in the dom tree
794 return;
795 }
796 var ancestors = [];
797 if (isTransformed) {
798 var t = this.text.parentElement;
799 while (t && t.nodeType == 1) {
800 ancestors.push(t);
801 t.setAttribute("ace_nocontext", "true");
802 if (!t.parentElement && t.getRootNode) t = t.getRootNode()["host"]; else t = t.parentElement;
803 }
804 }
805 this.text.focus({preventScroll: true});
806 if (isTransformed) {
807 ancestors.forEach(function (p) {
808 p.removeAttribute("ace_nocontext");
809 });
810 }
811 setTimeout(() => {
812 this.text.style.position = "";
813 if (this.text.style.top == "0px") this.text.style.top = top;
814 }, 0);
815 }
816
817 blur() {
818 this.text.blur();

Callers 15

gutter_test.jsFile · 0.45
mockdom.jsFile · 0.45
showSettingsMenuFunction · 0.45
$createCommandMethod · 0.45
$preventMouseEventMethod · 0.45
textarea.jsFile · 0.45
setupApiFunction · 0.45
promptFunction · 0.45
$initMethod · 0.45
hideMethod · 0.45

Calls 4

setAriaOptionsMethod · 0.95
pushMethod · 0.80
setAttributeMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected