Skip to content

Commit 1dcdc15

Browse files
committed
fix: readonly style on structure mode
1 parent f2a930d commit 1dcdc15

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

packages/pluggableWidgets/combobox-web/src/Combobox.editorConfig.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export function getPreview(_values: ComboboxPreviewProps, isDarkMode: boolean):
198198
const palette = structurePreviewPalette[isDarkMode ? "dark" : "light"];
199199
const structurePreviewChildren: StructurePreviewProps[] = [];
200200
let dropdownPreviewChildren: StructurePreviewProps[] = [];
201-
201+
let readOnly = _values.readOnly;
202202
if (
203203
_values.source === "context" &&
204204
_values.optionsSourceType === "association" &&
@@ -211,13 +211,19 @@ export function getPreview(_values: ComboboxPreviewProps, isDarkMode: boolean):
211211
)(_values.optionsSourceAssociationCustomContent)
212212
);
213213
}
214-
if (_values.source === "database" && _values.optionsSourceDatabaseCustomContentType !== "no") {
215-
structurePreviewChildren.push(
216-
dropzone(
217-
dropzone.placeholder("Configure the combo box: Place widgets here"),
218-
dropzone.hideDataSourceHeaderIf(false)
219-
)(_values.optionsSourceDatabaseCustomContent)
220-
);
214+
if (_values.source === "database") {
215+
if (_values.optionsSourceDatabaseCustomContentType !== "no") {
216+
structurePreviewChildren.push(
217+
dropzone(
218+
dropzone.placeholder("Configure the combo box: Place widgets here"),
219+
dropzone.hideDataSourceHeaderIf(false)
220+
)(_values.optionsSourceDatabaseCustomContent)
221+
);
222+
}
223+
224+
if (_values.databaseAttributeString.length === 0) {
225+
readOnly = _values.customEditability === "never";
226+
}
221227
}
222228
if (_values.source === "static" && _values.staticDataSourceCustomContentType !== "no") {
223229
structurePreviewChildren.push(
@@ -276,15 +282,15 @@ export function getPreview(_values: ComboboxPreviewProps, isDarkMode: boolean):
276282
borders: true,
277283
borderWidth: 1,
278284
borderRadius: 2,
279-
backgroundColor: _values.readOnly ? palette.background.containerDisabled : palette.background.container,
285+
backgroundColor: readOnly ? palette.background.containerDisabled : palette.background.container,
280286
children: [
281287
{
282288
type: "Container",
283289
grow: 1,
284290
padding: 4,
285291
children: structurePreviewChildren
286292
},
287-
_values.readOnly && _values.readOnlyStyle === "text"
293+
readOnly && _values.readOnlyStyle === "text"
288294
? container({ grow: 0, padding: 4 })()
289295
: {
290296
...getIconPreview(isDarkMode),

0 commit comments

Comments
 (0)