Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MountingPortal & :disabled="true" #297

Open
tybruffy opened this issue Apr 24, 2020 · 2 comments
Open

MountingPortal & :disabled="true" #297

tybruffy opened this issue Apr 24, 2020 · 2 comments

Comments

@tybruffy
Copy link

I feel like MountingPortal should properly account for the disabled state before it passes on data to Portal.

In my circumstance, I'd like to portal to an HTML element outside of my app, which may or may not exist. I have event listeners that will update my store state when the element is created, and I was using that listener to enable/disable the MountingPortal once I know the element exists.

Unfortunately, if the element to mount to doesn't exist when the created hook runs, it throws an error and never gets updated. It seems like this is something disabled should be able to handle, am I doing something wrong?

@tybruffy
Copy link
Author

Is this as simple as extracting the logic that runs in the created function currently to it's own method, and then running it when disabled changes/if disabled is not true on creation? Call that method something like register and then:

created() {
  if (!this.disabled) {
    this.register();
  }
}

and then adding a watcher for the disabled method?

watch: {
  disabled(newValue: boolean, oldValue: boolean) {
    if (newValue) {
      this.register();
    }
  },
}

@LinusBorg
Copy link
Owner

Makes sense, but realistically I won't work on this for now. I hardly have time to maintain the lib and still need to come up with a Vue 3 version for it soon.

If someone want to provide a tested PR I'm willing to give it a go though.

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

No branches or pull requests

2 participants