twenty icon indicating copy to clipboard operation
twenty copied to clipboard

Custom fields lacks empty tag

Open harshit078 opened this issue 1 year ago • 12 comments

Bug Description

  • Custom fields lacks empty tag as a result they have very limited clickable area to edit them.
  • This creates a lot of whitespaces in front of fields which hinders the design

Current behavior

Screenshot 2024-09-25 at 4 35 00 PM Screenshot 2024-09-25 at 4 54 13 PM

Expected

There should be empty tags in front of custom fields when empty

harshit078 avatar Sep 25 '24 11:09 harshit078

I cannot reproduce the bug 🤔 Any idea/ more context?

CleanShot 2024-09-25 at 14 00 31

Bonapara avatar Sep 25 '24 12:09 Bonapara

There was a mistake from my side on providing enough context @Bonapara. As you can see in the screen recording below, custom fields create empty spaces under company.

https://github.com/user-attachments/assets/cca98fd3-e4d4-467f-b0cc-ba6c049cf322

harshit078 avatar Sep 25 '24 13:09 harshit078

Could reproduce for relation custom fields in dropdowns, thanks @harshit078!

Bonapara avatar Sep 25 '24 15:09 Bonapara

/oss.gg 200

FelixMalfait avatar Oct 14 '24 19:10 FelixMalfait

Thanks for opening an issue! It's live on oss.gg!

oss-gg[bot] avatar Oct 14 '24 19:10 oss-gg[bot]

Hi, is this available to be taken? Can I work on this?

nganphan123 avatar Oct 16 '24 01:10 nganphan123

Hi @Bonapara , I did some inspection and it seems like the Empty tag is missing for Multi-select and One-to-many data type. The problem lies in the check isDisplayModeContentEmpty for empty content, which is referring to function isFieldValueEmpty() https://github.com/twentyhq/twenty/blob/1b99a05dec535167b68b062e1680f3dc7eebaa2b/packages/twenty-front/src/modules/object-record/record-inline-cell/components/RecordInlineCellDisplayMode.tsx#L89-L94

From what I understand, the isFieldValueEmpty() doesn't properly check if the array is empty. My solution would be adding changes to isFieldValueEmpty() to check the empty array for fields multi-select and relation.

Please let me know if I'm on the right track or if there's anything I've misunderstood. Thank you!

nganphan123 avatar Oct 16 '24 03:10 nganphan123

@lucasbordeau WDYT?

Bonapara avatar Oct 16 '24 09:10 Bonapara

@nganphan123 yes it seems you're on the right track! Thank you!

FelixMalfait avatar Oct 16 '24 15:10 FelixMalfait

@nganphan123 fyi we never really shiped relationToOne in the product in the end.

I'd probably do something like this instead (not tested):

if (isFieldRelation(fieldDefinition)) {
   if(isFieldRelationToOneValue(fieldValue)) {
       return isValueEmpty(fieldValue);
   }
    return  !isNonEmptyArray(fieldValue);
}

Close to what you're saying but better handling of RelationToOne imo (even though we don't use it)

FelixMalfait avatar Oct 17 '24 07:10 FelixMalfait

@FelixMalfait I see. I added the change and it passed the tests. Also, isFieldRelationToOneValue and isFieldRelationFromManyValue have the same implementation so it didn't identify which field is RelationToMany, so I changed to isArray instead.

  if (isFieldRelation(fieldDefinition)) {
    if (isArray(fieldValue)) {
      return !isNonEmptyArray(fieldValue);
    }
    return isValueEmpty(fieldValue);
  }

nganphan123 avatar Oct 17 '24 08:10 nganphan123

@FelixMalfait this issue can be closed since changes are merged

BOHEUS avatar Nov 02 '24 18:11 BOHEUS

Thanks @BOHEUS

FelixMalfait avatar Nov 03 '24 15:11 FelixMalfait