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 close dialog box editor notification #1228 #1249

Conversation

helioLJ
Copy link
Contributor

@helioLJ helioLJ commented Jul 5, 2023

  • Created a State to check if editor isClosedor not, by default it'sfalse`, since the dialog starts open.
  • Created a condition that it will return a fragment if isClosed it's true.
  • Created a function responsible for close the EditorNotification.
  • Passed closeEditor() to the Alert component.
  1. EditorNotification.js
  const [isClosed, setIsClosed] = React.useState(false)

  if (!hasEditingAccess(user, project) || isClosed) {
    return (<></>);
  }
  
  function closeEditor() {
    setIsClosed(true)
  }

  /*
  ...
  */

        <Alert handleClose={closeEditor} signal="notify">
  • Expected handleClose as a void function in AlertProps file.
  1. index.ts
export interface AlertProps {
  signal?: 'notify' | 'success' | 'error';
  handleClose?: () => void;
}
  • In Alert component, involved Icons.Close in a button to select it in StyledAlert.ts
  1. Alert.tsx
  <button>
    <Icons.Close onClick={handleClose} />
   </button>
  • Removed button border and background and added cursor pointer behavior.
  1. StyledAlert.ts
> button {
    border: none;
    background: none;
    cursor: pointer;
  }

@helioLJ helioLJ requested a review from a team as a code owner July 5, 2023 13:45
@changeset-bot
Copy link

changeset-bot bot commented Jul 5, 2023

⚠️ No Changeset found

Latest commit: 05339b0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@helioLJ helioLJ linked an issue Jul 5, 2023 that may be closed by this pull request
@@ -21,7 +22,9 @@ const Alert: React.FC<React.PropsWithChildren<AlertProps>> = ({
<></>
)}
<Typography css={{ flex: 1 }}>{children}</Typography>
<Icons.Close />
<button>
<Icons.Close onClick={handleClose} />
Copy link
Member

Choose a reason for hiding this comment

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

@helioLJ this is a great addition! thanks for adding handleClose prop.
can you please make the onClick on the button rather than the Icon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! I it will be more concise this way, ty

@@ -28,4 +28,10 @@ export const Container = styled.div<Styles>`
`;
}}
}

> button {
Copy link
Member

Choose a reason for hiding this comment

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

it's recommended to write it this way: & > button {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -1,4 +1,5 @@
export interface AlertProps {
signal?: 'notify' | 'success' | 'error';
handleClose?: () => void;
Copy link
Member

Choose a reason for hiding this comment

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

the type here is not so accurate handleClose?: (e?: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void; is more explicit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback, Mohammed! I'll make these changes soon as possible

Copy link
Member

Choose a reason for hiding this comment

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

@helioLJ I made a PR to fix those and also add animation to the alert #1253

@Devanshusp Devanshusp merged commit f5de099 into development/new-builds Jul 16, 2023
2 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot close dialog box on project page
3 participants