cal.com icon indicating copy to clipboard operation
cal.com copied to clipboard

close dropdown in teams to prevent z-index bug

Open PeerRich opened this issue 3 years ago β€’ 13 comments

problem

on https://app.cal.com/settings/teams when clicking

CleanShot 2022-07-28 at 13 58 21@2x

and selecting "disband team" it shows:

CleanShot 2022-07-28 at 13 57 20@2x

solution:

close dropdown when clicking "disband team"

PeerRich avatar Jul 28 '22 11:07 PeerRich

I tried to fix this issue and arrived at two solutions

  • currently the menu is being rendered in a portal and its z-index is 2147483646 if we pass portalled={false} to DropdownMenuContent in TeamListItem.tsx the issue is fixed
  • we can change the z-index of the Dialog component to 2147483647 which is one more than the z-index of the portal in which the DropdownMenuContent is being rendered

I tried to fix the zIndex of the Dropdown component but I guess Radix-UI doesn't allow to change it

sairajchouhan avatar Jul 28 '22 13:07 sairajchouhan

Hey, @PeerRich any thoughts on the above approaches?

sairajchouhan avatar Jul 29 '22 09:07 sairajchouhan

I tried to fix this issue and arrived at two solutions

  • currently the menu is being rendered in a portal and its z-index is 2147483646 if we pass portalled={false} to DropdownMenuContent in TeamListItem.tsx the issue is fixed
  • we can change the z-index of the Dialog component to 2147483647 which is one more than the z-index of the portal in which the DropdownMenuContent is being rendered

I tried to fix the zIndex of the Dropdown component but I guess Radix-UI doesn't allow to change it

why not close it? if possible we can change z-index but this problem would also be solved by just closing the dropdown

PeerRich avatar Jul 29 '22 13:07 PeerRich

Ya that would be a better approach

sairajchouhan avatar Jul 29 '22 20:07 sairajchouhan

I guess closing the dropdown is not what we should look for because we are stopping the click propagation at the modal trigger so the menu is not getting closed, even though we clicked the menu item, any feedback on this?

    <DropdownMenuItem>
                      <Dialog>
                        <DialogTrigger asChild>
                          <Button
                            onClick={(e) => {
                              e.stopPropagation();
                            }}
                            color="warn"
                            size="sm"
                            className="w-full rounded-none font-medium"
                            StartIcon={Icon.Trash}>
                            {t("disband_team")}
                          </Button>
                        </DialogTrigger>
                        <ConfirmationDialogContent
                          variety="danger"
                          title={t("disband_team")}
                          confirmBtnText={t("confirm_disband_team")}
                          isLoading={props.isLoading}
                          onConfirm={() => {
                            props.onActionSelect("disband");
                          }}>
                          {t("disband_team_confirmation_message")}
                        </ConfirmationDialogContent>
                      </Dialog>
                    </DropdownMenuItem>

sairajchouhan avatar Jul 29 '22 21:07 sairajchouhan

would need to see this in action, wanna open a PR?

PeerRich avatar Jul 29 '22 21:07 PeerRich

Ya sure

sairajchouhan avatar Jul 30 '22 06:07 sairajchouhan

There are currently two solution used in project:

  1. dropdown with ConfirmationDialogContent, like this place or remove team member

image

  1. or separate dialog with trigger button in dropdown like

image

the solution could be to prepare all dropdown like the second one, or add extra div like proposed PR https://github.com/calcom/cal.com/pull/3607

dezerb avatar Jul 30 '22 10:07 dezerb

I don't know which alternative is better. I wonder how the team behind radix-ui is thinking of this (since both components are from radix)

PeerRich avatar Jul 30 '22 13:07 PeerRich

@PeerRich I found discussion na radix github page. The solution is pretty straight forward and doesn't duplicate properties for potential new modals https://github.com/radix-ui/primitives/discussions/1436 I updated the PR https://github.com/calcom/cal.com/pull/3607. When it be accepted the same should be done for the "remove member" modal

dezerb avatar Jul 30 '22 21:07 dezerb

@PeerRich I found discussion na radix github page. The solution is pretty straight forward and doesn't duplicate properties for potential new modals

https://github.com/radix-ui/primitives/discussions/1436

I updated the PR https://github.com/calcom/cal.com/pull/3607. When it be accepted the same should be done for the "remove member" modal

we will review and merge on monday πŸ™ thank you

PeerRich avatar Jul 30 '22 23:07 PeerRich

I would want to work on this.

ivinayakg avatar Jan 01 '23 18:01 ivinayakg

go for it!

PeerRich avatar Jan 01 '23 21:01 PeerRich

this has been fixed a while ago

PeerRich avatar Jan 26 '23 13:01 PeerRich