@evoke-platform/ui-components 1.8.1-dev.0 → 1.8.1-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ export const ObjectPropertyInput = (props) => {
19
19
  const [layout, setLayout] = useState();
20
20
  const [layoutLoaded, setLayoutLoaded] = useState(false);
21
21
  const DEFAULT_CREATE_ACTION = '_create';
22
+ const hasValue = instance?.[property.id]?.id || selectedInstance?.id;
22
23
  useEffect(() => {
23
24
  setLayoutLoaded(false);
24
25
  if (relatedObject) {
@@ -198,8 +199,7 @@ export const ObjectPropertyInput = (props) => {
198
199
  } }, children));
199
200
  }, sx: {
200
201
  '& button.MuiButtonBase-root': {
201
- ...(!loadingOptions &&
202
- (instance?.[property.id]?.id || selectedInstance?.id)
202
+ ...(!loadingOptions && hasValue
203
203
  ? {
204
204
  visibility: 'visible',
205
205
  }
@@ -213,7 +213,15 @@ export const ObjectPropertyInput = (props) => {
213
213
  React.createElement(Box, null,
214
214
  React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px' } }, option.label),
215
215
  layout?.secondaryTextExpression ? (React.createElement(Typography, { sx: { marginLeft: '8px', fontSize: '14px', color: '#637381' } }, compileExpression(layout?.secondaryTextExpression, options.find((o) => o.id === option.value)))) : null)));
216
- }, onOpen: () => setOpenOptions(true), onClose: () => setOpenOptions(false), value: instance?.[property.id]?.id || selectedInstance?.id
216
+ }, onOpen: (e) => {
217
+ // Don't open the options if there is a value that links to another page
218
+ if (!(navigationSlug &&
219
+ navigateTo &&
220
+ ['DIV', 'INPUT'].includes(e.target?.nodeName) &&
221
+ hasValue)) {
222
+ setOpenOptions(true);
223
+ }
224
+ }, onClose: () => setOpenOptions(false), value: hasValue
217
225
  ? {
218
226
  value: instance?.[property.id]?.id ??
219
227
  selectedInstance?.id ??
@@ -241,7 +249,7 @@ export const ObjectPropertyInput = (props) => {
241
249
  setDropdownInput(undefined);
242
250
  return;
243
251
  }
244
- if (instance?.[property.id]?.id || selectedInstance?.id) {
252
+ if (hasValue) {
245
253
  e.preventDefault();
246
254
  }
247
255
  }, loading: loadingOptions, onChange: (event, value) => {
@@ -263,24 +271,18 @@ export const ObjectPropertyInput = (props) => {
263
271
  if (dropdownInput) {
264
272
  getDropdownOptions();
265
273
  }
266
- }, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', readOnly: !loadingOptions &&
267
- !!(instance?.[property.id]?.id ||
268
- selectedInstance?.id), onChange: (event) => setDropdownInput(event.target.value), onClick: (e) => {
274
+ }, renderInput: (params) => (React.createElement(TextField, { ...params, placeholder: 'Select', readOnly: !loadingOptions && !!hasValue, onChange: (event) => setDropdownInput(event.target.value), onClick: (e) => {
269
275
  if (navigationSlug &&
276
+ navigateTo &&
270
277
  ['DIV', 'INPUT'].includes(e.target?.nodeName) &&
271
- (instance?.[property.id]?.id ||
272
- selectedInstance?.id)) {
273
- if (navigateTo) {
274
- setOpenOptions(false);
275
- navigateTo(navigationSlug.replace(':instanceId', instance?.[property.id]?.id ??
276
- selectedInstance?.id ??
277
- ''));
278
- }
278
+ hasValue) {
279
+ setOpenOptions(false);
280
+ navigateTo(navigationSlug.replace(':instanceId', instance?.[property.id]?.id ??
281
+ selectedInstance?.id ??
282
+ ''));
279
283
  }
280
284
  }, sx: {
281
- ...(!loadingOptions &&
282
- (instance?.[property.id]?.id ||
283
- selectedInstance?.id)
285
+ ...(!loadingOptions && hasValue
284
286
  ? {
285
287
  '.MuiOutlinedInput-root': {
286
288
  background: 'white',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.8.1-dev.0",
3
+ "version": "1.8.1-dev.1",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",