# CM sets the focus again after re-entering the page

**URL:** <https://discuss.codemirror.net/t/cm-sets-the-focus-again-after-re-entering-the-page/3916>\
**Category:** v6\
**Created:** [January 18, 2022, 8:19am UTC](https://discuss.codemirror.net/t/cm-sets-the-focus-again-after-re-entering-the-page/3916 "2022-01-18T08:19:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![localhost](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/l/53a042/32.png) [@localhost](https://discuss.codemirror.net/u/localhost)\
**Post date:** [January 18, 2022, 8:19am UTC](https://discuss.codemirror.net/t/cm-sets-the-focus-again-after-re-entering-the-page/3916/1 "2022-01-18T08:19:59Z")

</div>

Hi there!  
I’m not sure it’s a bug or a feature 🙂

here’s how you can recreate it:

- click in the editor field
- open another page OR open a new tab OR click somewhere outside the browser window
- go back to the page with editor and see that the FOCUS event was triggered

Is this the expected behavior? Can I somehow prevent re-focus?

> **[adoring-perlman-7ho2w - CodeSandbox](https://codesandbox.io/s/adoring-perlman-7ho2w?file=%2Fsrc%2Findex.js)**
>
> adoring-perlman-7ho2w using @codemirror/basic-setup, @codemirror/view, parcel-bundler

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [January 18, 2022, 9:40am UTC](https://discuss.codemirror.net/t/cm-sets-the-focus-again-after-re-entering-the-page/3916/2 "2022-01-18T09:40:02Z")

</div>

I’m not seeing this in Firefox, which suggests it is browser behavior — browsers have rather complicated heuristics for when to focus things on load. The editor itself definitely has no (intentional) autofocus feature.
