Skip to content

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

FEATURE: do not insert smart list if SHIFT+Enter is pressed (#29452)

Sam4d7f70b92399
diff --git a/app/assets/javascripts/discourse/app/components/d-editor.js b/app/assets/javascripts/discourse/app/components/d-editor.js
index a1c863b30fa..00ae361da04 100644
--- a/app/assets/javascripts/discourse/app/components/d-editor.js
+++ b/app/assets/javascripts/discourse/app/components/d-editor.js
@@ -379,6 +379,10 @@ export default class DEditor extends Component {
"beforeinput",
this.onBeforeInputSmartList
);
+ this._textarea.addEventListener(
+ "keydown",
+ this.onBeforeInputSmartListShiftDetect
+ );
this._textarea.addEventListener("input", this.onInputSmartList);
}
@@ -415,11 +419,18 @@ export default class DEditor extends Component {
}
}
+ @bind
+ onBeforeInputSmartListShiftDetect(event) {
+ this._shiftPressed = event.shiftKey;
+ }
+
@bind
onBeforeInputSmartList(event) {
// This inputType is much more consistently fired in `beforeinput`
// rather than `input`.
- this.handleSmartListAutocomplete = event.inputType === "insertLineBreak";
+ if (!this._shiftPressed) {
+ this.handleSmartListAutocomplete = event.inputType === "insertLineBreak";
+ }
}
@bind
@@ -490,6 +501,10 @@ export default class DEditor extends Component {
"beforeinput",
this.onBeforeInputSmartList
);
+ this._textarea.removeEventListener(
+ "keydown",
+ this.onBeforeInputSmartListShiftDetect
+ );
this._textarea.removeEventListener("input", this.onInputSmartList);
}
}