Feature #43259 » 0001-wiki-toolbar-keep-textarea-focus.patch
| app/javascript/controllers/wiki_toolbar_controller.js | ||
|---|---|---|
| 32 | 32 |
if (!this.field) return |
| 33 | 33 | |
| 34 | 34 |
if (!this.editorTarget.contains(this.field)) {
|
| 35 |
// Moving the element reconnects the controller |
|
| 35 |
// Moving the element removes the focus and reconnects the controller |
|
| 36 |
this.focusField = document.activeElement === this.field |
|
| 36 | 37 |
this.field.before(this.element) |
| 37 | 38 |
this.editorTarget.prepend(this.field) |
| 38 | 39 |
} |
| ... | ... | |
| 41 | 42 |
.catch((error) => console.error(`Wiki toolbar syntax not found for ${this.formatValue}`, error))
|
| 42 | 43 |
this.addShortcutsToTitles() |
| 43 | 44 |
this.element.hidden = false |
| 45 |
if (this.focusField) this.field.focus() |
|
| 46 |
this.focusField = false |
|
| 44 | 47 |
} |
| 45 | 48 | |
| 46 | 49 |
disconnect() {
|