Skip to content

Request: allow the use of a portal for the popover #67

@Trekiros

Description

@Trekiros

Describe the solution you'd like

I would like to use this component within a scrollable container, in a way where the popover isn't clipped by the scrollable container
image

Describe alternatives you've considered

I have tried to use a portal to achieve this effect.

    const ref = useRef()

    return (
            <ReactTags
                renderListBox={({ children, ...props }) => !ref.current ? <></> : createPortal(
                    <div
                        {...props} 
                        className={styles.listBox} 
                        style={{ top: (ref.current.offsetTop + ref.current.clientHeight) + "px", left: ref.current.offsetLeft + "px" }}
                        onFocus={e => e.stopPropagation()}>
                            {children}
                    </div>,
                    document.body
                )}
                
                ... />
    )

However, when you click on anything outside of the ReactTags component (and due to the portal, the listbox is now considered outside), the listbox is removed. This happens before your click is able to add a tag from the list of suggestions.

Because of this, I believe this is a change that has to happen within the library itself, rather than in the code where I use the library. At least, I haven't been able to find a property which would allow me to cancel the removal of the listbox myself (note: this is what I tried to do with the onFocus prop - I also tried onClick, onMouseDown, and onBlur on the main component)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions