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

Reset modal after adding event #442

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

romanstetsyk
Copy link
Contributor

Description

Reset the form after adding an event by clicking the 'close' button or clicking on the modal backdrop.

Type of change

Please select everything applicable. Please, do not delete any lines.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • This change requires an update to testing

Issue

Checklist:

  • This PR is up to date with the main branch, and merge conflicts have been resolved
  • I have executed npm run test and all tests have passed successfully or I have included details within my PR on the failure.
  • I have executed npm run lint and resolved any outstanding errors. Most issues can be solved by executing npm run format
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings

@romanstetsyk romanstetsyk temporarily deployed to DEV August 17, 2023 17:42 — with GitHub Actions Inactive
Copy link
Member

@intelagense intelagense left a comment

Choose a reason for hiding this comment

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

Good job. This should do the trick while we wait to start on a redesigned event modal. 👍

<Backdrop
onClick={() => {
context.handleClose();
if (typeof onBackdropClick === "function") onBackdropClick();
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this conditional should silently pass if a "function" typed onBackdropClick isn't passed as a prop.

If someone is adding more modals later but accidentally passes an onBackdropClick of some type other than "function", this if will essentially hide that error.

Instead, it might be better to just check for the existence of onBackdropClick. Then if a non-function prop is passed to Modal it will easily be caught during testing.

Suggested change
if (typeof onBackdropClick === "function") onBackdropClick();
if (onBackdropClick) onBackdropClick();

@@ -2,7 +2,7 @@ import { AnimatePresence } from "framer-motion";
import Backdrop from "./Backdrop";
import { motion } from "framer-motion";

Copy link
Contributor

@cblanken cblanken Sep 9, 2023

Choose a reason for hiding this comment

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

Optionally you could add a check for the onBackdropClick type with prop-types. That way you get an error on page load if an invalid onBackdropClick prop is passed in instead of at runtime.

Suggested change
import PropTypes from "prop-types";
// Modal component definition
Modal.propTypes = {
onBackdropClick: PropTypes.func,
};

Like this
image

Copy link
Contributor

Choose a reason for hiding this comment

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

If a redesign for the event modal is in the works like @intelagense mentioned then this may not be that important. Just my two cents.

Copy link
Member

Choose a reason for hiding this comment

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

If a redesign for the event modal is in the works like @intelagense mentioned then this may not be that important. Just my two cents.

I'm not sure the redesign will be coming anytime soon.

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.

4 participants