You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2026/04/09 23:07:33 UTC
(superset) 01/01: fix(dataset-editor): fix SQL expression editor extra spaces and height expansion
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch sql-expr-editor-fix
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 60eb309ec5cecf99f026203d3306084704fd07c3
Author: Maxime Beauchemin <ma...@gmail.com>
AuthorDate: Thu Apr 9 16:16:04 2026 +0000
fix(dataset-editor): fix SQL expression editor extra spaces and height expansion
Prevent the `value` prop from leaking through to ReactAce via rest
spread, which caused the editor to operate in controlled mode and
produce extra spaces on input. Also increase maxLines from 10 to 25
for both computed column and metric expression editors so the editor
auto-expands with content, and add overflow:auto when resize is
enabled so the CSS resize handle works properly.
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
---
.../DatasourceEditor/DatasourceEditor.tsx | 47 +++++++++++++++-------
.../components/controls/TextAreaControl.tsx | 4 +-
2 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx b/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
index 5b6ccf91527..1745a584e90 100644
--- a/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
+++ b/superset-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
@@ -66,6 +66,7 @@ import {
Loading,
Row,
Select,
+ Tooltip,
Typography,
Label,
} from '@superset-ui/core/components';
@@ -394,6 +395,7 @@ const EditLockContainer = styled.div`
font-size: ${({ theme }) => theme.fontSizeSM}px;
display: flex;
align-items: center;
+ padding: ${({ theme }) => theme.paddingSM}px 0;
a {
padding: 0 10px;
}
@@ -578,7 +580,8 @@ function ColumnCollectionTable({
<TextAreaControl
language="sql"
offerEditInModal={false}
- resize="vertical"
+ maxLines={25}
+ debounceDelay={300}
/>
}
/>
@@ -2180,6 +2183,19 @@ class DatasourceEditor extends PureComponent<
expandFieldset={
<FormContainer>
<Fieldset compact>
+ <Field
+ fieldKey="expression"
+ label={t('SQL expression')}
+ control={
+ <TextAreaControl
+ language="sql"
+ offerEditInModal={false}
+ minLines={3}
+ maxLines={25}
+ debounceDelay={300}
+ />
+ }
+ />
<Field
fieldKey="description"
label={t('Description')}
@@ -2262,7 +2278,10 @@ class DatasourceEditor extends PureComponent<
})}
itemCellProps={{
expression: () => ({
- width: '240px',
+ style: {
+ maxWidth: '240px',
+ overflow: 'hidden',
+ },
}),
}}
itemRenderers={{
@@ -2290,18 +2309,18 @@ class DatasourceEditor extends PureComponent<
verbose_name: (v, onChange) => (
<TextControl value={v as string} onChange={onChange} />
),
- expression: (v, onChange) => (
- <TextAreaControl
- canEdit
- initialValue={v as string}
- onChange={onChange}
- extraClasses={['datasource-sql-expression']}
- language="sql"
- offerEditInModal={false}
- minLines={5}
- textAreaStyles={{ minWidth: '200px', maxWidth: '450px' }}
- resize="both"
- />
+ expression: (v: unknown) => (
+ <Tooltip title={t('Expand row to edit')}>
+ <Typography.Text
+ code
+ ellipsis
+ css={css`
+ cursor: default;
+ `}
+ >
+ {v as string}
+ </Typography.Text>
+ </Tooltip>
),
description: (v, onChange, label) => (
<StackedField
diff --git a/superset-frontend/src/explore/components/controls/TextAreaControl.tsx b/superset-frontend/src/explore/components/controls/TextAreaControl.tsx
index f1e5fbd138d..f0aa16ced79 100644
--- a/superset-frontend/src/explore/components/controls/TextAreaControl.tsx
+++ b/superset-frontend/src/explore/components/controls/TextAreaControl.tsx
@@ -160,6 +160,7 @@ class TextAreaControl extends Component<TextAreaControlProps> {
readOnly,
name,
onChange,
+ value,
minLines: minLinesProp,
maxLines: maxLinesProp,
...editorProps
@@ -176,6 +177,7 @@ class TextAreaControl extends Component<TextAreaControlProps> {
};
if (resize) {
style.resize = resize;
+ style.overflow = 'auto';
}
if (readOnly) {
style.backgroundColor = theme?.colorBgMask;
@@ -206,7 +208,7 @@ class TextAreaControl extends Component<TextAreaControlProps> {
maxLines={inModal ? 1000 : maxLinesProp}
editorProps={{ $blockScrolling: true }}
onLoad={onEditorLoad}
- defaultValue={initialValue}
+ defaultValue={initialValue || value}
readOnly={readOnly}
key={name}
{...editorProps}