Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Enable autocorrect in the topic composer on mobile

Jake Goldsborough94586bf2945b
diff --git a/frontend/discourse/app/components/composer/textarea-editor.gjs b/frontend/discourse/app/components/composer/textarea-editor.gjs
index 13b8da4e05d..c4d35a79166 100644
--- a/frontend/discourse/app/components/composer/textarea-editor.gjs
+++ b/frontend/discourse/app/components/composer/textarea-editor.gjs
@@ -114,6 +114,7 @@ export default class TextareaEditor extends Component {
}}
@aria-label={{@placeholder}}
@autocomplete="off"
+ @autocorrect="on"
@disabled={{@disabled}}
@focusIn={{@focusIn}}
@focusOut={{@focusOut}}
diff --git a/frontend/discourse/app/static/prosemirror/components/prosemirror-editor.gts b/frontend/discourse/app/static/prosemirror/components/prosemirror-editor.gts
index e9f46c27894..c2dcdf5447c 100644
--- a/frontend/discourse/app/static/prosemirror/components/prosemirror-editor.gts
+++ b/frontend/discourse/app/static/prosemirror/components/prosemirror-editor.gts
@@ -279,7 +279,10 @@ export default class ProsemirrorEditor extends Component<ProsemirrorEditorSignat
this.view = new EditorView(container, {
state,
nodeViews: extractNodeViews(this.extensions, params),
- attributes: { class: this.args.class ?? "" },
+ attributes: {
+ class: this.args.class ?? "",
+ autocorrect: "on",
+ },
editable: () => this.args.disabled !== true,
dispatchTransaction: (tr) => {
this.view.updateState(this.view.state.apply(tr));
diff --git a/frontend/discourse/tests/integration/components/composer-editor-test.gjs b/frontend/discourse/tests/integration/components/composer-editor-test.gjs
index 962504ac2f7..25780eef0a2 100644
--- a/frontend/discourse/tests/integration/components/composer-editor-test.gjs
+++ b/frontend/discourse/tests/integration/components/composer-editor-test.gjs
@@ -89,4 +89,15 @@ module("Integration | Component | ComposerEditor", function (hooks) {
"Rich editor placeholder text is correct"
);
});
+
+ test("enables autocorrect and disables autocomplete on the textarea", async function (assert) {
+ await render(<template><ComposerEditor /></template>);
+
+ assert
+ .dom(".d-editor-input")
+ .hasAttribute("autocorrect", "on", "enables autocorrect suggestions");
+ assert
+ .dom(".d-editor-input")
+ .hasAttribute("autocomplete", "off", "keeps browser autofill disabled");
+ });
});
diff --git a/frontend/discourse/tests/integration/components/prosemirror-editor/prosemirror-editor-test.gjs b/frontend/discourse/tests/integration/components/prosemirror-editor/prosemirror-editor-test.gjs
index 5611f4e7aae..b0abeef1afe 100644
--- a/frontend/discourse/tests/integration/components/prosemirror-editor/prosemirror-editor-test.gjs
+++ b/frontend/discourse/tests/integration/components/prosemirror-editor/prosemirror-editor-test.gjs
@@ -28,6 +28,17 @@ module("Integration | Component | ProsemirrorEditor", function (hooks) {
assert.dom(".ProseMirror").exists("it renders the ProseMirror editor");
});
+ test("enables autocorrect on the editable element", async function (assert) {
+ await render(<template><ProsemirrorEditor /></template>);
+ assert
+ .dom(".ProseMirror")
+ .hasAttribute(
+ "autocorrect",
+ "on",
+ "enables autocorrect suggestions on mobile"
+ );
+ });
+
test("renders the editor with a null initial value", async function (assert) {
await render(<template><ProsemirrorEditor @value={{null}} /></template>);
assert.dom(".ProseMirror").exists("it renders the ProseMirror editor");