[FIX] web: CodeEditor: restore scrollability
Before this commit, the CodeEditor made Ace display infinity lines in height. This prevented Ace to be scrollable in some contexts. Specifically, when Ace was in a flex context, the scroll did not work. After this commit, the CodeEditor takes an optional maxLines props to pass to Ace. If not set, Ace will just adapt the number of lines to the size it gets. closes odoo/odoo#124656 X-original-commit: eb81a4c857a249e4cd2f28b455d87b64a8e93c9a Related: odoo/enterprise#42367 Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
@@ -40,6 +40,7 @@ export class CodeEditor extends Component {
|
||||
optional: true,
|
||||
validate: (theme) => CodeEditor.THEMES.includes(theme),
|
||||
},
|
||||
maxLines: { type: Number, optional: true },
|
||||
};
|
||||
static defaultProps = {
|
||||
readonly: false,
|
||||
@@ -68,7 +69,7 @@ export class CodeEditor extends Component {
|
||||
this.aceEditor = aceEditor;
|
||||
|
||||
this.aceEditor.setOptions({
|
||||
maxLines: Infinity,
|
||||
maxLines: this.props.maxLines,
|
||||
showPrintMargin: false,
|
||||
});
|
||||
this.aceEditor.session.setOptions({
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
onChange.bind="handleChange"
|
||||
class="'ace-view-editor'"
|
||||
theme="theme"
|
||||
maxLines="200"
|
||||
/>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
@@ -99,6 +99,7 @@ QUnit.module("Web Components", (hooks) => {
|
||||
mode="'xml'"
|
||||
value="state.value"
|
||||
onChange.bind="onChange"
|
||||
maxLines="200"
|
||||
/>
|
||||
`;
|
||||
setup() {
|
||||
|
||||
Reference in New Issue
Block a user