Skip to content

Suggestion:Change event listening to document from click to mousedown or mouseup. #55

@jsnb2333

Description

@jsnb2333

The reason is that the event firing order of mousedown and mouseup is before the click event. This can avoid race problems very well.

The core function is implemented by bubbling to document, so if the user acts on the external element of v-onclickaway through the set click event, the trigger time will always be earlier than the trigger of the v-onclickaway callback function. This will cause if the user's click event callback and v-onclickaway callback modify the same state (there is a race problem), then the final result is always the modified result of the v-onclickaway callback (this is not desirable, because v-onclickaway callbacks are usually basic behavior, and the user's click priority should be higher than the basic behavior).

Please refer to https://github.com/ElemeFE/element/blob/dev/src/utils/clickoutside.js practice

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