twenty icon indicating copy to clipboard operation
twenty copied to clipboard

View becomes blank after deleting select

Open Us3r-gitHub opened this issue 1 year ago • 6 comments

Bug Description

View becomes blank once we delete the select field that is currently being used.

image

Steps to Reproduce:

  1. Create new Select field
  2. Create new View-Kanban (use Select field that created before)
  3. Delete Select field on Settings Page
  4. Back again to View Page (it shows blank)

Expected behavior

Delete corresponding view simultaneously once select field is deleted. Add confirmation window to inform user that several views will be removed.

Us3r-gitHub avatar Jun 25 '24 23:06 Us3r-gitHub

To resolve the issue where the view becomes blank after deleting a select field, follow these steps:

  1. Modify view deletion logic:

    • Update the useViews, useViewFilters, and useViewSorts hooks to handle the deletion of views when the associated select field is deleted. Ensure that these hooks check for the existence of the select field and remove the corresponding views if the field is deleted.
  2. Add confirmation window:

    • Update the ViewPickerCreateOrEditContent and ViewPickerCreateOrEditContentEffect components to include a confirmation window. This window should inform the user about the views that will be removed when the select field is deleted.

Example code snippets:

useViews.js:

// Add logic to delete views associated with the deleted select field
useEffect(() => {
  if (deletedSelectField) {
    const updatedViews = views.filter(view => view.fieldId !== deletedSelectField.id);
    setViews(updatedViews);
  }
}, [deletedSelectField]);

ViewPickerCreateOrEditContent.js:

// Add confirmation window logic
const handleDeleteSelectField = (fieldId) => {
  const affectedViews = views.filter(view => view.fieldId === fieldId);
  if (affectedViews.length > 0) {
    if (window.confirm(`Deleting this field will remove ${affectedViews.length} views. Do you want to proceed?`)) {
      deleteSelectField(fieldId);
    }
  } else {
    deleteSelectField(fieldId);
  }
};

Ensure these changes are integrated into the respective files and tested for the described scenario.

References

Edit Issue Bot Settings

greptile-apps[bot] avatar Jun 25 '24 23:06 greptile-apps[bot]

@Weiko https://github.com/twentyhq/twenty/issues/6028 may be related to this one too if you have any inputs?

Bonapara avatar Jul 02 '24 09:07 Bonapara

The mentioned issue will be the next impact if this is not addressed/fixed

After this object field deletion and navigate back to view again

Us3r-gitHub avatar Jul 02 '24 10:07 Us3r-gitHub

@Bonapara is it ok to delete the view directly when deleting the field, or should we add a modal when deleting the field to warn that the view will be deleted ?

ijreilly avatar Jul 04 '24 15:07 ijreilly

We can delete it directly, at least for now!

Bonapara avatar Jul 05 '24 09:07 Bonapara

Here is the GitStart Ticket for this issue: https://clients.gitstart.com/twenty/5449/tickets/TWNTY-6027

gitstart-app[bot] avatar Jul 31 '24 08:07 gitstart-app[bot]