-
-
Notifications
You must be signed in to change notification settings - Fork 980
improve <Portal/>
container, add 2 new properties
#2502
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
base: main
Are you sure you want to change the base?
Conversation
- `asElement` allows to change Portal container element type - `class` allows to set class for Portal container
|
I wonder, if defaulting the container with this inline style will solve it is possible to hack it as shown here if Portal has intentions to support fragments in the future ( no wrapper ) it is nice however to have control of the container element however and its styling. |
I'm not sure I would want a hacky solution. It is not friendly with accessibility since Fragment support is nice though. |
one more thing |
Yeah, when I made this, I didn't think that far. But you are right. It should support all html attributes. We can do that with @mizulu what's your thought? |
first of all before you make any more changes, I would wait for @ryansolid feedback. now back to the discussion <Portal
element={()=>{<div/>}}
fallback={()=>{}}
style={} class={} attr:id={"portal_1"} prop:tabIndex={0}>
</Portal> but if we do it this way, I don't know if Portal will be able to narrow its type to and if we already pass an element, perhaps the better api for this will simply be <Portal
element={()=><div class={myclass} attr:id="portal_1" />}
fallback={()=>{}}>
</Portal> some more considerations:
|
The truth is we are redesigning Portal's in 2.0. I figured out a way to use proxies to proxy DOM elements that will allow us to get rid of the intermediate DOM element. So while I know it is a bit clunky right now I'm less incentivized to change the API to encourage patterns that will be going away anyway. For now messing with the ref is probably the way to go. |
@ryansolid |
No because it is a breaking change. It could be implementable but I can't change the existing Portal that way. |
If there is no plan to backport, then maybe we should allow the user to control the wrapper container <Portal
element={()=><div class={myclass} attr:id="portal_1" />} >
</Portal> or more simply just pass the constructor string <Portal
element="p" > using ref is already an awkward pattern , which is going to be "broken" in v2.0 allowing this will remove one more barrier from users who are happy with solid 1.0 we can consider enabling fragmented portals in solid 1.0 by flag, as to not make it a breaking change. <Portal element={<></>}/>
or
<Portal fragment /> |
I don't know what is "three mandatory fields" since I only saw 2 headings. But I filled all of them.
Summary
Bascially, I don't like a bare
<div/>
wrap children component so I would like to suggest make Portalcontainer
be more customisable with tagName and class. We can find a way to support dataset later if it requires.How did you test this change?
I've update test file and run test script from
package.json
s:/
→pnpm test
cd ./packages/solid
→pnpm test
Both of them return all pass results so I assume there is nothing would break the framework. As for testing on real field, I'm not sure how to do that yet.