Skip to content

Commit

Permalink
Hide single choice required behaviors in compact properties
Browse files Browse the repository at this point in the history
  • Loading branch information
4ian committed Sep 19, 2024
1 parent 1f73056 commit b65c5ec
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ const createField = (
property.getExtraInfo().size() > 0 ? property.getExtraInfo().at(0) : '';
return {
name,
isHiddenWhenOnlyOneChoice: true,
valueType: 'string',
getChoices: () => {
return !object || behaviorType === ''
Expand Down
23 changes: 13 additions & 10 deletions newIDE/app/src/CompactPropertiesEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,16 +620,19 @@ const CompactPropertiesEditor = ({
(field: ValueField) => {
if (!field.getChoices || !field.getValue) return;

const children = field
.getChoices()
.map(({ value, label, labelIsUserDefined }) => (
<SelectOption
key={value}
value={value}
label={label}
shouldNotTranslate={labelIsUserDefined}
/>
));
const choices = field.getChoices();
if (choices.length < 2 && field.isHiddenWhenOnlyOneChoice) {
return;
}

const children = choices.map(({ value, label, labelIsUserDefined }) => (
<SelectOption
key={value}
value={value}
label={label}
shouldNotTranslate={labelIsUserDefined}
/>
));

let compactSelectField;
if (field.valueType === 'number') {
Expand Down

0 comments on commit b65c5ec

Please sign in to comment.