question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rendering a custom popover

See original GitHub issue

Feature – I have enable isSelectable in my calendar, but want to have the user select a few timeslots and have a popup menu being rendered after they have selected. Essentially, I want to render a react component after onSelectSlot is called. Is there any way to do this?

The only thing i can think of right now is injecting something in the DOM when onSelectSlot is called but I can’t take advantage of react then. I don’t see a react class i can override in components for this either.

Does anyone have any suggestions?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
arecvlohecommented, Jul 30, 2018

I am closing this for now since the original poster is not active. Thanks @joshuawootonn for your response!

1reaction
Bielik20commented, May 13, 2020

I stumbled opon this issue trying to figure out correct way of introducing popovers to calendar (quite common use case). I ended up doing it like that:

export function EventPopoverWrapper({ children, popover }: Props): any {
  const [anchorEl, setAnchorEl] = React.useState<HTMLDivElement | null>(null);

  const handleClick = (event: React.MouseEvent<HTMLDivElement>) => {
    setAnchorEl(event.currentTarget);
  };

  const handleClose = () => {
    setAnchorEl(null);
  };

  const open = Boolean(anchorEl);
  const id = open ? 'simple-popover' : undefined;

  return (
    <>
      <div aria-describedby={id} onClick={handleClick}>
        {children}
      </div>
      <Popover
        id={id}
        open={open}
        anchorEl={anchorEl}
        onClose={handleClose}
        anchorOrigin={{
          vertical: 'bottom',
          horizontal: 'center',
        }}
        transformOrigin={{
          vertical: 'top',
          horizontal: 'center',
        }}
      >
        {popover}
      </Popover>
    </>
  );
}

Then in actual calendar:

          eventWrapper: props => (
            <EventPopoverWrapper
              {...props}
              popover={
                <OffAssignmentsCalendarPopover
                  assignment={props.event}
                  userEntities={userEntities}
                />
              }
            />
          ),
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Render a React Component Inside a Bootstrap Popover
This guide will further explore this scenario and offer two approaches for rendering a component inside a bootstrap popover.
Read more >
Rendering a custom popover · Issue #871 · jquense/react-big ...
I have enable isSelectable in my calendar, but want to have the user select a few timeslots and have a popup menu being...
Read more >
Rendering a React component inside a Bootstrap popover
Bootstrap doesn't make it easy to render a dynamic component within a popover. If the popover you want to present is static, you...
Read more >
Reusable Popovers to Add a Little Pop | CSS-Tricks
Step 1: Create the BasePopover component · Step 2: Initialize popper.js · Step 3: Destroy Popper · Step 4: Render BasePopover component ·...
Read more >
Rendering a Bootstrap Popover using ASP.NET Core Razor ...
Let's see how to render a popover using a dedicated Razor Page and a jQuery AJAX call. Samples included!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found