-
Notifications
You must be signed in to change notification settings - Fork 247
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 frameworks using constant context value #397
base: main
Are you sure you want to change the base?
Conversation
This is by design -- React/angular/etc. components are inline by definition, so need to be in iframe mode. To open a popup you would need to wait for a user event like a click, then manually call |
@bluepnume the render method by default uses an iframe. Forcibly passing the context constant not only overrides the defaultContext option on the component's definition but also makes the docs misleading and this option obselete altogether |
Sure but Example:
|
It is quite clear by the name This is quite problematic and unexpected because, when a driver renders the component, it overrides the component's Example:
|
I think I'm not quite following -- why would the event listener use the driver in step 3, but then manually call |
you understand my point correctly. When using the driver pattern, the app cannot control the This PR addresses the explicit argument |
I guess let me rephrase the question; what do you want to happen with a driver render in the case that defaultContext is a popup? Do you want zoid to render a popup in that case? |
Yes. Currently it enforces an iframe: Line 62 in eb8677a
|
Right, so that's the underlying problem here. Normally browsers only allow you to open a popup on a user-initiated click or keyboard event -- and only synchronously. Whereas many rendering libraries, including I think React, do not synchronously render on click. That will mean a lot of the time your popup will completely blocked from opening by the browser. So if you want to open a popup, my recommendation would be to explicitly listen for a click or keyboard event, then manually call |
That's a fair work around. Regardless of how it should be done, the defaultContext value should be coming from component's definition instead being hard coded as it currently. The default value of defaultContext is iframe. This PR addresses it. |
I'm really not sure I agree. The logic as it stands is:
Not to mention -- this is a backwards incompatible change, right? Given that there could be zoid components out there which are currently relying on that 1.b. behavior of "Render to a popup by default, but fall back to an inline iframe if the caller uses a driver (since in that case the in-built browser popup-blocker will be triggered)". What is the actual use-case you're hoping to unblock here? Are you trying to render a popup through one of the drivers, and are you not getting popup-blocked when you test this? |
My use case is I cannot render a popup using the driver pattern as it forces an iframe over component definition options. The code that I am targeting is only
This is backwards compatible in that, it will render to a popup by default, but will fall back to an inline iframe if the caller uses a driver since the default value of defaultContext will be References: zoid/src/component/component.js Line 354 in eb8677a
zoid/src/component/component.js Line 184 in eb8677a
|
That is an artifact. It's not always the case. My browser on the other hand allows popup by default. I want the React driver to adopt |
Also, notice that I have not allowed the popup by default. I am using chrome and my apps renders the driver component only when the user does an action. It is problematic because the driver then does not use my Notice that it is not necessary for the driver to explicitly pass References: Line 85 in eb8677a
zoid/src/component/component.js Line 354 in eb8677a
zoid/src/component/component.js Line 184 in eb8677a
|
Sure, but the default behavior is to block in every browser I've ever used. Are you working in an environment where users of your component will have to change their browser settings before using your component?
Not really - libraries like React force components to be asynchronously rendered, right? So even using a click event won't help much here. |
This sounds like an over generalisation to optimize user experience essentially by handicapping the app to render a popup when using the driver (More at end). The current design violates two SOLID principles (Learn More):
FYI; all versions of react do not force asynchronous rendering. Learn More |
Thanks for the demo! OK I'm convinced. If you can trigger a synchronous render through React, that's good enough for me. That said: there is still a backwards-compatibility question here; there could be users of zoid who are currently relying on the behavior of defaulting to a popup, but falling back to an iframe when using any one of the drivers. So let's brainstorm a little on an interface that can allow us to override the default behavior and also preserve backwards compatibility. A few ideas:
|
Currently, the
*Correction: notice that currently the behavior is default to
Which is the actual intent of the app i.e render popup using driver, as opposed to being overridden by the driver with an Parent props should have a |
I think I'd be happy with this solution. It's not really a traditional 'prop' in that it's not needed in the child window/frame. But it avoids any backwards compatibility problems. |
This reverts commit eb08a0c.
Feature: context parent-prop
Please take a look at the changes now. Here is a brief summary of this PR:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #397 +/- ##
=======================================
Coverage 95.51% 95.52%
=======================================
Files 18 18
Lines 1182 1184 +2
=======================================
+ Hits 1129 1131 +2
Misses 53 53 ☔ View full report in Codecov by Sentry. |
@bluepnume please update on this |
Hello sir @artmanque, i'm using zoid with vue3, do you know how i can configure the component correctly? the error that i have say My configuration is this export default Breakout; |
@JoseIsra i suggest you to try running vue3 example from this PR before testing it in your app |
@artmanque how can i use zoid from its own repository. Do you have some sample code to follow? I can clone the repo and run the setup script, the package json says that. But after that? I'm new in this library-repository use case u.u |
react/angular/angular2/vue/vue3 components call
render
method using a constantCONTEXT.IFRAME
overriding user'sdefaultContext
fromcreate
optionsFixes #393