-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feat: implement DeleteGroupDialog #248
Feat: implement DeleteGroupDialog #248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanta1207
Thank you for researching the issue of how to prevent the dialog from unintentionally closing together when the dropdown menu is closed. I couldn't even find any solution when I tried.
However, I still doubt this approach, although it works here.
Wrap GroupCardDropdownMenu with DialogRoot, and put DeleteGroupConfirmDialog outside of drop down menu because if DialogRoot goes inside of GroupCardDropdownMenuContent, closing the dropdown will also close the dialog.
The reason is that with this approach, we would not be able to have two or more dialogs within the same dropdown menu. Here are the cases we should face shortly:
Review Points
The trigger is in GroupCardDropdownMenuContent, content is in GroupCardDropdownMenu. Is this component structure complexity okay?
I think the complexity is acceptable as long as the comments are appropriately written.
If not, not using DialogTrigger to open the dialog can be an another solution.
I am wondering if not using the DialogTrigger
may degrade the accessibility.
We may need to discuss this.
</DropdownMenuTrigger> | ||
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} /> | ||
</DropdownMenu> | ||
// Wrapping dialog menu with DialogRoot. Trigger is in GroupCarDropdownMenuContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, but could you please clarify this comment? It's a bit difficult to understand what it's trying to say.
I could be like the following if my understanding is correct:
The
<DropdownMenu>
must be wrapped with the<DialogRoot>
to prevent the dialog from closing unintentionally when the dropdown menu is closed. The trigger for the dialog can be found in the<GroupCarDropdownMenuContent>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was addressed by adjusting DeleteGroupDialog
to follow how it's implemented in DeleteFoodDialog
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my perspective, naming this component DeleteGroupDialogContent
(without "confirmation") is understandable enough. The name DeleteGroupConfirmDialogContent
sounds to me like a "second" dialog to confirm the deletion. You can decide it. However, since our design has multiple delete dialogs, we should prioritize consistency across the project. You can decide :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the file name to DeleteGroupDialog
!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has changed just because I removed FC
type.
I did the change only to this file for now because the file was in this PR's scope. Maybe I'll refactor rest of FC
types in other files later in different scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed the file name to DeleteGroupDialog
!
</DropdownMenuTrigger> | ||
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} /> | ||
</DropdownMenu> | ||
// Wrapping dialog menu with DialogRoot. Trigger is in GroupCarDropdownMenuContent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue was addressed by adjusting DeleteGroupDialog
to follow how it's implemented in DeleteFoodDialog
.
@@ -122,7 +122,7 @@ export const deleteMember = async ( | |||
): Promise<Result<undefined, string>> => { | |||
try { | |||
await request({ | |||
url: `${BACKEND_API_DOMAIN}/groups/${groupId}/users/${userId}`, | |||
url: `${API_BASE_URL}/groups/${groupId}/users/${userId}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found out thisBACKEND_API_DOMAIN
variable (which doesn't exist) is set as base url in here, and caused build error. The functionality shouldn't be also working tho, don't know how it's in develop branch now...
@nick-y-ito Please take a look at the change when you have time 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanta1207
Thank you for updating! Please kindly take a look at the comments. They are not as crucial as I have to request changes.
However, I suppose the dropdown menu should be closed together when closing the dialog. If you are planning to implement that behavior in the next PR, please never mind :)
If you address this and need my further review, please feel free to ask me again!
* This is necessary because closing dropdown menu also closes the dialog unintentionally. | ||
* @see {@link https://www.radix-ui.com/primitives/docs/components/dropdown-menu#item} | ||
* | ||
* @param e The event object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minor thing, though; here is the official way of formatting the @param
tag. It is good to be aware of.
/**
* @param e - The event object
*/
<DialogTitle>Delete Group</DialogTitle> | ||
</DialogHeader> | ||
<DialogBody> | ||
<p>Are you sure you want to delete group?</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Are you sure you want to delete 'this' group?" would sound slightly better.
Icon, | ||
} from '@/components/ui'; | ||
|
||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe unnecessary
DialogTitle, | ||
} from '@/components/ui'; | ||
|
||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am sorry, I found an error in the console after I approved. That says:
app-index.js:35 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Could you inspect it, please?
delete-container-dropdown-menu-error.mov
@nick-y-ito
I just forgot to implement the functionality in this PR, so I included it in commit #9c5e7d2.
Sorry that I didn't notice the warning in the first place. I should've checked that. Please kindly take a look at them again on your convenience 🙏 |
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="w-12"> | ||
<Icon icon={MenuKebabIcon} size={4.5} /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I separated GroupCardDropdownMenuContent
from trigger as a different component,
I ended up having to pass onDropdownMenuClose
prop from this file, and it's props drilling among 4 layers.
(GroupCardDropdownMenuTriggerButton
=> GroupCardDropdownMenuContent
=> DeleteGroupDialogTriggerButton
=> DeleteGroupDialogContent
)
The directory structure itself is reasonable one tho, let me know if you feel we have to do something for this props drilling. I personally chose to keep this directory structure for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally chose to keep this directory structure for now.
I agree. I think it's acceptable for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanta1207
Thank you for updating!
I think the dropdown menu should also be closed when after the [ Delete ] button is clicked.
There is another problem with this behavior, though...
#269
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" className="w-12"> | ||
<Icon icon={MenuKebabIcon} size={4.5} /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<GroupCardDropdownMenuContent handleRenameClick={handleRenameClick} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally chose to keep this directory structure for now.
I agree. I think it's acceptable for now.
Thank you for your review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanta1207
Thank you for fixing them promptly! Looks good to go 😄
* Feature: create container feature(UI) in group single page (#256) * feat: implemenet drawer UI" * feat: implement UI of creating container drawer * chore: delete console.log * fix: change the first letter of file name to lower case * fix: add a type to the function parameter * fix: change to self-closing * fix: avoid using type annotation * docs: add docs to interface and function * fix(creategroupdrawercontent.tsx): add param, change to self-closing in whicht it referenced from * Feature: add delete functionality to the members page (#268) * fix: adjust menuIcon and 'Members' in MembersPage * feat: implement popup DropdownMenu when clicked only UI" * feat: implement member delete dialog * refactor: create on click function * feat: disable dialog and dropdown at same time when button clicked * chore: delete unnecessary code * test: set up for deleting-member function * docs: add docs to interfaces and functions * test: change the way of comparison to primitive * test: add schema for validation * docs: add doc to the handling function for delete button * docs: add doc to interface IMemberPageProps * fix: typo * fix: change onClick event to one line * Feature: Add validation to the DELETE food (#266) * feat: add validation to the DELETE food * feat: revise the ID validation for CREATE & UPDATE food * Feature: Adjust environment variables and deploy on Vercel (#267) * refactor: rename env LOCALHOST_URL * refactor: rename env BACKEND_API_DOMAIN * refactor: unify OAuth Domain and Redirect URL * chore: clarify the env.example * fix: gitignore for env * Feature: Create container feature api in group single page (#272) * feat: pass groupId to child * feat: implement fetch function * test: test for postContainer * fix: change Domain variable * test: implement test for action * test: implement test for API error * feat: implement call API when submit * docs: add docs to interface and function * docs: typo * fix: modified variable and put a link in docs to improve readability * docs: add doc for more descriptive * refactor: move createContainer function to top for readability * refactor: change the function name from postContainer to postCreateContaier * fix: typo * refactor: separate container and food test function * Feat: implement DeleteGroupDialog (#248) * feat: implement deleteGroupConfirmDialog * feat: re-implement delete group dialog with new file structure * fix: out of scope, env variable name * fix: restructure to close dropdown menu on dialog close * fix: remove unnecessary asChild in DropdownMenuItem * fix: close dropdown on closing dialog * Docs: Relocate the content of NOTE documents (#276) * refactor: refactor & add TSDocs in Icon.tsx * docs: remove note docs * docs: add Icons sections to the style guide * refactor: rename icon components to improve accessibility * Docs: Improve `README.md` & `CONTRIBUTING.md` (#281) * Feature: Apply a correct link to the back button of each page (#271) * feat: allow the Link component to accept any attributes * feat: correct the back link for foods page * feat: create API client and apply group name to header * refactor: rename GroupSingle * style: add line break * chore: allow leading underscore for variable names * fix: correct env and solve the compile error * Feat : implement delete group api client (#282) * feat: implement delete group api client * refactor: refactor TsDoc comments for existing action functions * feat: add remove group action * refactor: refactor group action file * feat: apply api client to delete dialog component * fix: fix following coding style guide * fix: refactor TsDoc comments to add info * Feature: Rename container UI in group single page (#287) * feat: implement UI of DropdownMenu * feat: implement switching container name to input field * feat: add 1rem padding to right side of input * docs: add docs to interface and function * style: formatting for readability * docs: add docs to the function which it is missing * fix: change default font size of input from ld to md * refactor: change the event props name to onXXX * fix: change type to alias * Feature: Apply design changes to Select.tsx (#249) * style(select.tsx): changed some styles to match the Figma design * style(select.tsx): added a wrapper to check icon to align with the Figma design #127 * style(select.tsx): added className that was accidentally deleted in the previous commit #127 * style(select.tsx): fixed icon name #127 * style(select.tsx): applied style changes to the icon #127 * Feature: Rename container api in group single page (#297) * feat: implement UI of DropdownMenu * feat: implement switching container name to input field * feat: add 1rem padding to right side of input * docs: add docs to interface and function * style: formatting for readability * fix: update Icon name * feat: implement putRenameContainer function * docs: add docs to the function which it is missing * fix: change default font size of input from ld to md * refactor: change the event props name to onXXX * refactor: delete unnecessary file * feat: implement API call * fix: change type to alias * feat: pass containerId to child components * feat: implement test without validation * test: add validation test * docs: add comment on function * style: add lines * docs: add doc to renameContainer functions * style: add lines for readability * fix: update the messages * fix: update the message in test * refactor: change the structure in action for readability * fix: create a gap between each card * fix: modify the position of icon when error appears * fix: typo * fix: change the approach to self-start * Feature: Disable authentication for contributors (#290) * feat: create auth utils * feat: disable login flow * feat: disable toke check when using mock API * feat: update .env.example * feat: copy .env.example to .env.local on `postinstall` * chore: add comments in .env.example * test: fix test for request function * refactor: increase the readability * Feature: Adjust the UI & behavior of the login form (#286) * feat: added google login icon * feat: google login with reac-ui amplify * feat: rm unused code * refactor: remove unused styles in tailwind.config.ts * refactor: define color variables in CSS * feat: add spinner image * feat: create the WhiteOverlay UI component * feat: adjust the style and behavior of the login form * ci: update the node version * chore: remove unnecessary google image * ci: update the node version * feat: set timeout to prevent indefinite loading --------- Co-authored-by: kotaaaa <kota.k.1132.pda@gmail.com> * Feature: Delete container UI in group single page (#306) * feat: implement displaying dialog * docs: add docs to function and interface * chore: adjust the documentation * docs: typo * docs: update the content * docs: update doc * docs: add doc where missing * docs: add missing symbol for doc * docs: fix the explanation * docs: fix the explanation * Fix: Highlight the bottom icons on sub pages (#302) * Chore: Add pre-push hook to run test (#301) * ci: add pre-push hook to run test * Revert "ci: add pre-push hook to run test" This reverts commit d01a418. * ci: add pre-push hook to run test * Docs: Improve Community Standards (#307) * docs: create SECURITY.md * docs: create `CODE_OF_CONDUCT.md` * Feat : Get users name in profile page (#308) * feat: implement getCurrentUserId api client * test: test getCurrentUser api client * fix: fix api client to resolve with the issue #255 * refactor: refactor the TSDoc comment in authApiClient * feat: implement getUserById API client * feat: apply api clients to Profile page * refactor: remove unnecessary temp solution * refactor: update the comments in api client * test: test getUserByUserId function * refactor: add comments * refactor: update TSDoc comments * refactor: add issue reference in Profile page * fix: return => returns in getUserName TSDoc * fix: duplicate import line in userApiClient.server * fix: relative import path to absolute * refactor: add better comment to getUserName function * refactor: add TSDoc comment to UserProfile prop interface * fix: remove return types from TSDoc * refactor: add line break before `it` * refactor: use template literal * refactor: use template literal * refactor: update TSDoc and add error handling to throw error * fix: remove relative path * fix: remove relative path * test: refactor test to make it better --------- Co-authored-by: ShoeheyOt <142355969+ShoeheyOt@users.noreply.github.com> Co-authored-by: kanta1207 <99339182+kanta1207@users.noreply.github.com> Co-authored-by: Anukrati Mehta <anukratimehta@gmail.com> Co-authored-by: kotaaaa <kota.k.1132.pda@gmail.com>
Overview
Implement
DeleteGroupConfirmDialog
component.Changes
DialogRoot
, and putDeleteGroupConfirmDialog
outside of drop down menu because ifDialogRoot
goes inside ofGroupCardDropdownMenuContent
, closing the dropdown will also close the dialog.DeleteGroupConfirmDialog
component.GroupCardDropdownMenuContent
.Review points
GroupCardDropdownMenuContent
, content is inGroupCardDropdownMenu
. Is this component structure complexity okay? If not, not usingDialogTrigger
to open the dialog can be an another solution.Screen Captures
Screen.Recording.2024-02-21.at.12.36.52.mov
Assignee Checklist:
Reviewer Checklist: