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

[Bug]: #93

Closed
airowe opened this issue Jul 20, 2022 · 2 comments · Fixed by #94
Closed

[Bug]: #93

airowe opened this issue Jul 20, 2022 · 2 comments · Fixed by #94
Assignees
Labels
bug Something isn't working

Comments

@airowe
Copy link

airowe commented Jul 20, 2022

What happened?

Attempting to implement atcb_action on custom button component results in triggerElement being undefined.

How to reproduce?

export const AddToCalendar: React.VFC<Props> = ({ appointment }) => {
  const saveToCalendar = useCallback(
    (e) => {
      e.preventDefault();
      atcb_action({
        trigger: 'click',
        name: `${appointment?.visit_reason}`,
        startDate: `${formatApptDate(appointment?.start_time)}`,
        endDate: `${formatApptDate(appointment?.end_time)}`,
        startTime: `${formatApptTime(appointment?.start_time)}`,
        endTime: `${formatApptTime(appointment?.end_time)}`,
        location: `${addressToString(appointment?.clinic.address)}`,
        options: ['Apple', 'Google', 'iCal', 'Microsoft365', 'Outlook.com', 'Yahoo'],
        timeZone: 'America/Los_Angeles',
        iCalFileName: 'Reminder-Event',
      });
    },
    [appointment?.clinic.address, appointment?.end_time, appointment?.start_time, appointment?.visit_reason]
  );

  return (
    <IconButton
      onClick={saveToCalendar}
      icon={<CalendarIcon />}
    />
  );
};

Screenshots & more

image

System & Environment

Chrome on MacBook

1.11.2

@airowe airowe added the bug Something isn't working label Jul 20, 2022
jekuer added a commit that referenced this issue Jul 20, 2022
@jekuer jekuer linked a pull request Jul 20, 2022 that will close this issue
Merged
2 tasks
@jekuer
Copy link
Collaborator

jekuer commented Jul 20, 2022

Thanks, @airowe .
Fixed with latest version.

Despite that, I would recommend to also provide the tiggerElement (compary to the final examples at the demo page or Readme). This makes sure that closing the modal will re-focus the triggering element (important for keyboard navigation).
But it is optional now (again).

@jekuer jekuer self-assigned this Jul 20, 2022
@airowe
Copy link
Author

airowe commented Jul 21, 2022

Thanks for being so responsive! I couldn't get the triggerElement to be passed in successfully to atcb_action but would love to know how to do that in the future.

Your fix works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants