Skip to content

[Bug] Popup automatically close when append-to-body is false #759

@dallefeste

Description

@dallefeste

Vue2-datepicker version: 3.11.1
Vue version: 2.6.11
Browser: chrome

Steps to reproduce
I've integrated the vue2-datepicker with the 'append-to-body' flag set to true, and the component works properly. However, when I change it to false (since I'm integrating it into a web component), it correctly places the popup in the right DOM element. However, upon selecting a date (including any click inside the popup), it closes the popup without capturing the selected date or date range.

Reproduction Link or Source Code

<div style="position: relative;">
    <date-picker 
        ref="datepicker"
        :append-to-body="false"
        timeTitleFormat="MM"
        :editable="false"
        :confirm="false"
        @pick="handlePickDate"
        @open="handleOpenPopupEvent"
        @close="handleClosePopupEvent"
        :disabled-date="disabledRangeHandler"
        v-model="rangeDate" 
        format="DD MMM YY"
        valueType="date"
        range-separator=" - "
        :range="isRange"
    >
    </date-picker>
    <div ref="target" style="position: relative;"></div>
</div>

And in the js:

mounted: function () {
    const el = this.$refs.datepicker.$refs.popup.$el;
    this.$refs.target.appendChild(el);
}

Thank you for your work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions