Skip to content
This repository was archived by the owner on Nov 9, 2024. It is now read-only.
This repository was archived by the owner on Nov 9, 2024. It is now read-only.

Tippy ignores plugins' "onShow" lifecycle hook returning false. #644

Closed
@some-sam

Description

@some-sam

Bug description

If a plugin's lifecycle hook for "onShow" returns false, it is ignored and the tip is shown anyway. This seems unexpected.

Suggestion

Fixing this would be rather tricky, as there can be some ambiguous cases (one plugin returning false, another not, etc). I suggest updating the "lifecycle" docs to denote that returning false from a plugin has no effect.

Workaround

My workaround is to override the onShow prop in onCreate. Please let me know if this seems reasonable and future-proof:

    const myPluginThatSometimesCancelsShow = {
        fn: function() {
            return {
                onCreate: function(instance) {
                    const origOnShow = instance.props.onShow;
                    instance.props.onShow = function(){
                        if ( /* some internal logic */ ) { return false; }
                        if (origOnShow) return origOnShow();
                    }
                },
            }
        }
    };

Activity

atomiks

atomiks commented on Nov 23, 2019

@atomiks
Owner

Yeah I agree. The ability to return false from those is not really composable so it's limited to the props hooks only.

atomiks

atomiks commented on Nov 24, 2019

@atomiks
Owner

I wouldn't recommend monkey-patching as you've done really due to conflicts as you mentioned. It's not composable - here's a good article as to why. You might run into weird bugs later on down the track due to it and forget that there's a plugin causing the problem 😭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @some-sam@atomiks

        Issue actions

          Tippy ignores plugins' "onShow" lifecycle hook returning false. · Issue #644 · atomiks/tippyjs