Fix rating field not editable if null (#6110)

## Context

Rating fields were not editable on the show page and kanban view when
they were null, this is because we don't have a way to leave the empty
state for fields that are editModeContentOnly.
~~This is actually an issue for bool fields (which is the other field
type that has editModeContentOnly) as well but they have default values
can't go be edited to NULL so it's not visible.~~
Actually let's fix bool, this could happen too

Hovering over "Empty" will now show the RatingField edit mode.
I'm not 100% sure about this solution though, we could also make this
behaviour on click? I preferred over since this is the behaviour on the
table view 🤔

## Test


https://github.com/twentyhq/twenty/assets/1834158/6825b5c3-2c62-41f2-8e03-343bc0e895e2
This commit is contained in:
Weiko
2024-07-03 15:13:41 +02:00
committed by GitHub
parent 4183e5460d
commit c57c5b2554

View File

@ -3,6 +3,7 @@ import styled from '@emotion/styled';
import { useFieldFocus } from '@/object-record/record-field/hooks/useFieldFocus';
import { useIsFieldEmpty } from '@/object-record/record-field/hooks/useIsFieldEmpty';
import { useIsFieldInputOnly } from '@/object-record/record-field/hooks/useIsFieldInputOnly';
import { RecordInlineCellContainerProps } from '@/object-record/record-inline-cell/components/RecordInlineCellContainer';
import { RecordInlineCellButton } from '@/object-record/record-inline-cell/components/RecordInlineCellEditButton';
@ -76,6 +77,10 @@ export const RecordInlineCellDisplayMode = ({
!isDisplayModeContentEmpty &&
!editModeContentOnly;
const isFieldInputOnly = useIsFieldInputOnly();
const shouldDisplayEditModeOnFocus = isFocused && isFieldInputOnly;
return (
<>
<StyledRecordInlineCellNormalModeOuterContainer
@ -84,7 +89,8 @@ export const RecordInlineCellDisplayMode = ({
isHovered={isHovered}
>
<StyledRecordInlineCellNormalModeInnerContainer>
{isDisplayModeContentEmpty || !children ? (
{(isDisplayModeContentEmpty && !shouldDisplayEditModeOnFocus) ||
!children ? (
<StyledEmptyField>{emptyPlaceholder}</StyledEmptyField>
) : (
children