fix: handle removing first item from Contact and links#2128
fix: handle removing first item from Contact and links#2128davehakkens merged 5 commits intomasterfrom
Conversation
Passing run #3047 ↗︎Details:
This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. |
|||||||||||||||
|
Working on a test to capture this fix. Think it will need to be at the e2e level as we don't have much testing infrastructure at a lower level around these pages. |
|
Visit the preview URL for this PR (updated for commit 162bebe): https://onearmy-next--pr2128-fix-removing-first-i-qwt8q33h.web.app (expires Fri, 21 Apr 2023 21:16:42 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6d65e4f8fee2f6ab2da0c1c3b85b8797d66afa59 |
|
Same behaviour on Preview. |
d3822ad to
f7d29ee
Compare
|
Thanks for taking a look @davehakkens and catching that debugging alert. I have added an automated linter to catch those in future. I will play about with this a bit more locally, it makes sense that if you add a few more links you should be able to delete the first item. Although I understand that we also expect there to be one item entered. |
|
@davehakkens, updated so that the Delete button is only available if there are multiple fields available. There is only a single field available: There are multiple links added so any one can be removed. Although it is not possible to safe a profile using an empty value |
Nice solution @thisislawatts. However the first/top url doest get removed here when i click delete button. Delete works for all the other ones but not the first |
|
Thanks for taking a look @davehakkens, I imagine that is why the tests are failing. Will circle back around to this tomorrow evening. |
a068f7c to
162bebe
Compare
|
Is this ready to test again @thisislawatts ? |
|
Please do |
|
works perfect 👌 |
There was a problem hiding this comment.
Looks good @thisislawatts, great idea to add uuid as a key for the links!
Thought: Seeing as we are using a modal for the profile link deletion, as seen here, it could be nice to create a reusable modal.
I've noticed there are a few of these delete modals in the code base which would benefit from this as well (eg in HowtoStep.form and OpeningHoursPicker.field. This would help make sure that any change to the modal design can be applied easily across all components. Moreover, we could also then use it for the deletion of comments as well maybe?
I don't think this should this should fall into the scope of this bug fix, but could be something to as a potential issue if you agree?
| } | ||
|
|
||
| async function handleDelete(_id: string) { | ||
| // eslint-disable-next-line no-alert |
There was a problem hiding this comment.
Question: are we planning on making these into custom modals down the line?
| // eslint-disable-next-line no-alert | ||
| const confirmation = window.confirm( | ||
| 'Are you sure you want to delete this comment?', | ||
| ) |
This is a reusable Modal element from
Definitely worth raising something like Consistent use of alert/modal as a separate issue, these are not consistent across the site and I think it would be great to make this experience a bit smoother. Specifically on this page I do not think an alert/modal is necessary as the removal action is not immediately destructive. The user needs to click 'Save' before the change will be persisted. |
Ah I didn't realize it was a custom component, my bad, I assumed it was something like The state of the modal could then be stored in something like context or redux, not sure if either is used for the project. This would avoid having to have all the logic for opening and closing the modals inside of each component. Maybe this is just overcomplicating something that is fine, and most likely not very much a priority, but it just stuck out to me as not being very DRY.
Yes definitely, as I was going through the site at times it felt odd to use the modal and then later on have the window popout instead. I'll look into raising a issue relating to more consistent use of modals! |
|
🎉 This PR is included in version 1.41.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |




PR Checklist
PR Type
Description
Fixes an issue that occurs when attempting to remove the first list item from Contacts and Links.
Seems to be coming from: https://github.com/ONEARMY/community-platform/blob/master/src/pages/Settings/content/formSections/Fields/Link.field.tsx#L136:L136
Related chatter:
GitIssuesCloses issue reported:
https://discord.com/channels/586676777334865928/1079116300133072897/1079116300133072897