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

Close portal from within portal

Open robsco opened this issue 4 years ago • 2 comments

I've added an extra "reset" button to the portal, which works fine with my app, but I also need it to close the portal.

Is there a way of doing this?

This is my implementation:

(this.clearDate acts similar to this.handleChangeDate).

            <DatePicker
                selected={ dateFromIso( this.props.list.date, false ) || new Date() }
                onChange={ this.handleChangeDate }
                withPortal
                customInput={ div }
            >
                <p onClick={ this.clearDate }>Clear</p>
            </DatePicker>

robsco avatar Sep 22 '21 11:09 robsco

I've managed to solve it using ref.current.setOpen method. Couldn't find anything in docs, so I don't know if this is a proper approach, but it works for me 😅 Codesandbox: https://codesandbox.io/s/react-datepicker-close-from-container-v3x18

rago4 avatar Dec 31 '21 14:12 rago4

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 10 '22 13:07 stale[bot]