react-popover icon indicating copy to clipboard operation
react-popover copied to clipboard

Popover with no children

Open jeanbza opened this issue 7 years ago • 6 comments

This does not work:

<Popover isOpen={this.state['popoverVisible']} body='hello from popover!' />

This does:

<Popover isOpen={this.state['popoverVisible']} body='hello from popover!'><div></div></Popover>

It'd be nice if both worked =)

jeanbza avatar Nov 08 '16 23:11 jeanbza

Hey @jadekler

It seems that you want to be able to create the popover without a target? If so, wouldn't that just basically be a modal? Let me know more about your intention, I'd love to understand.

jasonkuhrt avatar Jan 23 '17 02:01 jasonkuhrt

children shouldn't be required in case we want to appendTarget, btw target is the same thing as children which is confusing at first and setting appendTarget is overridden by target, how can it be solved?

anissaSanadtech avatar Oct 20 '17 16:10 anissaSanadtech

Hey @anissaSanadtech I'm a bit confused. appendTarget is about where the portal will be mounted in the DOM. Sometimes controlling this is desirable. children is the visual target of the popover, the thing the popover is going to "point" at. They each serve very different purposes. Am I missing something?

jasonkuhrt avatar May 16 '18 00:05 jasonkuhrt

@jasonkuhrt My issue is that sometimes I can't use children as the object I want to tie the tooltip - it doesn't render - however using it like in @jadekler example is ideal in my app. I just wish it would allow for the self-closing tags. I think https://github.com/littlebits/react-popover/pull/178 is all that is needed for this change.

kaloudis avatar May 18 '18 12:05 kaloudis

@kaloudis What do you expect popover to do given:

<Popover isOpen={true} body='foobar' />

Where is it going to render? What will its x/y coordinates be? Can you show me a code example with a bit more context?

jasonkuhrt avatar May 18 '18 13:05 jasonkuhrt

@jasonkuhrt in my case it renders wherever I place it in the app - so long as isOpen is set to true. I realize different people have their apps set up differently - in many cases they're required to set a child component to latch on to but as in my case and in @jadekler's, it's not required.

Currently my code looks sorta like this:

<div onClick={() => this.setState({open: true})}>
   <Popover
       isOpen={this.state.open}
       className="popover"
       preferPlace="below"
       onOuterAction={() => this.setState({open: false})}
       tipSize=".01" // disable tip
       body={
          <HuntHistory close={() => this.setState({openHuntHistory: false}) } />
       }
     ><div></div></Popover>
</div>

kaloudis avatar May 18 '18 15:05 kaloudis