Fixed reset rating field to "no value" on star re-click (#6296)
### Description Resolves Issue: [https://github.com/twentyhq/twenty/issues/6224](#6224) ### Additional Consideration I have changed the default start rating value from 1 star to no star since clicking on the selected start was reverting the filed to 1 star which didn't seem like the appropriate behaviour. Let me know if this change is fine --------- Co-authored-by: JosephAshwin23 <joseph.sanjivi@anywhere.co> Co-authored-by: Thomas Trompette <thomas.trompette@sfr.fr>
This commit is contained in:
@ -7,7 +7,9 @@ import { FieldRatingValue } from '@/object-record/record-field/types/FieldMetada
|
||||
import { RatingInput } from '@/ui/field/input/components/RatingInput';
|
||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||
|
||||
const convertFieldRatingValueToNumber = (rating: FieldRatingValue): string => {
|
||||
const convertFieldRatingValueToNumber = (
|
||||
rating: Exclude<FieldRatingValue, null>,
|
||||
): string => {
|
||||
return rating.split('_')[1];
|
||||
};
|
||||
|
||||
@ -51,6 +53,10 @@ export const ObjectFilterDropdownRatingInput = () => {
|
||||
<RatingInput
|
||||
value={selectedFilter?.value as FieldRatingValue}
|
||||
onChange={(newValue: FieldRatingValue) => {
|
||||
if (!newValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
selectFilter?.({
|
||||
id: selectedFilter?.id ? selectedFilter.id : v4(),
|
||||
fieldMetadataId: filterDefinitionUsedInDropdown.fieldMetadataId,
|
||||
|
||||
@ -16,14 +16,14 @@ export const useRatingField = () => {
|
||||
|
||||
const fieldName = fieldDefinition.metadata.fieldName;
|
||||
|
||||
const [fieldValue, setFieldValue] = useRecoilState<FieldRatingValue | null>(
|
||||
const [fieldValue, setFieldValue] = useRecoilState<FieldRatingValue>(
|
||||
recordStoreFamilySelector({
|
||||
recordId: entityId,
|
||||
fieldName: fieldName,
|
||||
}),
|
||||
);
|
||||
|
||||
const rating = fieldValue ?? 'RATING_1';
|
||||
const rating = fieldValue ?? null;
|
||||
|
||||
return {
|
||||
fieldDefinition,
|
||||
|
||||
@ -185,7 +185,7 @@ export type FieldAddressValue = {
|
||||
addressLat: number | null;
|
||||
addressLng: number | null;
|
||||
};
|
||||
export type FieldRatingValue = (typeof RATING_VALUES)[number];
|
||||
export type FieldRatingValue = (typeof RATING_VALUES)[number] | null;
|
||||
export type FieldSelectValue = string | null;
|
||||
export type FieldMultiSelectValue = string[] | null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user