Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:Empty link in record details isn't deleted by default #9840

Merged
merged 5 commits into from
Feb 4, 2025

Conversation

Lucifer4255
Copy link
Contributor

Gives a fix for #9780 . I have added handleDelete inside the submit function and created a state to manage the empty placeholder
Screencast from 2025-01-24 01-45-22.webm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds functionality to handle empty link deletion in record details, ensuring that empty links are properly removed when a user clears the input field.

  • Added isClearingInput state in MultiItemFieldInput.tsx to track input clearing status
  • Modified handleSubmitInput to trigger item deletion when input is cleared
  • Improved empty string validation using turnIntoEmptyStringIfWhitespacesOnly utility
  • Integrated with existing link field components to maintain consistent behavior

1 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Contributor

@etiennejouan etiennejouan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Lucifer4255, thank you for your PR.

Your solution is not handling case where input is empty string (without update).

I would handle empty string input in handleSubmitInput method.

  • If inputValue is empty string AND isAddingNewItem, it should early return
  • If inputValue is empty string AND !isAddingNewItem, it should delete updated item and early return

Copy link
Contributor

@etiennejouan etiennejouan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lucifer4255 thank you for your update, added few comments.

Copy link
Contributor

@prastoin prastoin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me !
Shouldn't the API reject empty value for objectMetadata field links ? What kind of server side validation do we wanna reach to on objectMetadaItem fields ?

@prastoin prastoin merged commit 0675017 into twentyhq:main Feb 4, 2025
48 checks passed
Copy link
Contributor

github-actions bot commented Feb 4, 2025

Fails
🚫

node failed.

Log

�[31mError: �[39m SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:5591:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:5562:27)�[39m
�[90m    at fullyReadBody (node:internal/deps/undici/undici:1665:9)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m
�[90m    at async specConsumeBody (node:internal/deps/undici/undici:5571:7)�[39m
danger-results://tmp/danger-results-dab24ed0.json

Generated by 🚫 dangerJS against 3ff3710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants