twenty icon indicating copy to clipboard operation
twenty copied to clipboard

fix: RightDrawer doesn't save context values when clickedOutside

Open harshit078 opened this issue 1 year ago • 3 comments

Description

  • This PR fixes the issue #7728

Changes

https://github.com/user-attachments/assets/1e66cab3-9009-4c01-9ac6-22651b0ff5e7

harshit078 avatar Oct 15 '24 21:10 harshit078

Hello @harshit078, thank you for contributing :) Even if your solution works, I'm not sure that it is the right approach. The bug happens because closeRightDrawer is a recoilCallback and is thus executed outside of the flow of react. I asked @lucasbordeau why it was that way and apparently it was needed for the email threads. I think the right solution is to rename closeRightDrawer to closeRightDrawerRecoilCallback inside useRightDrawer and to export closeRightDrawer like this:

const setIsRightDrawerOpen = useSetRecoilState(isRightDrawerOpenState);
const setIsRightDrawerMinimized = useSetRecoilState(
    isRightDrawerMinimizedState,
  );
 const closeRightDrawer = () => {
    setIsRightDrawerOpen(false);
    setIsRightDrawerMinimized(false);
  };

I'll let @charlesBochet and @lucasbordeau confirm though.

bosiraphael avatar Oct 16 '24 14:10 bosiraphael

/award 200

charlesBochet avatar Oct 31 '24 12:10 charlesBochet

Awarding harshit078: 200 points 🕹️ Well done! Check out your new contribution on oss.gg/harshit078

oss-gg[bot] avatar Oct 31 '24 12:10 oss-gg[bot]

@harshit078 We want to avoid debouncing as it is non deterministic.

Could you try with useListenRightDrawerClose ? Maybe in the drawer title component ?

lucasbordeau avatar Nov 06 '24 09:11 lucasbordeau

@harshit078 When we need to debounce, it's generally a code smell because it means the underlying logic is too complex, we'll work on that to refactor this part, so the logic to persist a field can be deterministically and easily called before closing the right drawer.

lucasbordeau avatar Nov 06 '24 10:11 lucasbordeau

Follow-up issues : https://github.com/twentyhq/core-team-issues/issues/192 and https://github.com/twentyhq/core-team-issues/issues/160

lucasbordeau avatar Nov 06 '24 10:11 lucasbordeau

Thanks @harshit078 for your contribution! This marks your 36th PR on the repo. You're top 1% of all our contributors 🎉 See contributor page - Share on LinkedIn - Share on Twitter

Contributions

github-actions[bot] avatar Nov 06 '24 10:11 github-actions[bot]

Sentry Issue: TWENTY-FRONT-2TZ

sentry[bot] avatar Nov 18 '24 08:11 sentry[bot]