-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix(vue-3): Correctly set editor's appContext.provide to forward full inject chain #5397
fix(vue-3): Correctly set editor's appContext.provide to forward full inject chain #5397
Conversation
🦋 Changeset detectedLatest commit: a71fca4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 54 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Let's continue discussion in this PR @nperez0111 if you don't mind. I can add an example and tests as you said. But wouldn't it get picked up by the docs automatically? I'm sure we want to avoid that. |
If it is a new example, it wouldn't get picked up by the docs. The docs have to import the example, so it is fine to include new ones here |
… properly forward complete chain of injected values. fixes ueberdosis#5394 Vue internally uses prototype chain to preserve injects across the entire component chain. Thus should avoid Object.assign or spread operator as it won't copy the prototype. All correct provides will be already present on `instance.provides`.
7e22771
to
a71fca4
Compare
Added test coverage, this is ready to review. Had to slightly adjust |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really appreciate the additional tests & example. Just the one question & we can get this into the next release
// Vue internally uses prototype chain to forward/shadow injects across the entire component chain | ||
// so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext | ||
// @ts-expect-error forward instance's 'provides' into appContext | ||
provides: instance.provides, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to make sure, does this work for both the options API & composition API. I'm not familiar enough with vue to know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this will work for both Options and Composition API. Tbh I wrote tests in Composition first and then converted to Options for consistency with other examples.
Also no need to worry about composition vs options at all: Options API is literally implemented on top of Composition primitives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the confirmation!
Fixes #5394.
Changes Overview
Replace usage of
Object.assign
and setappContext.provides
as-is from current instanceprovides
.Implementation Approach
Vue internally uses prototype chain to preserve injects across the entire component chain. Thus should avoid
Object.assign
or spread operator as it won't copy the prototype. All correct provides will be already present oninstance.provides
.Testing Done
Added new example with cypress test coverage.
Verification Steps
Additional Notes
Checklist
Related Issues