<dialog/> CSS ::backdrop settings not being applied to cond'ly rendered dialog
Attached is my react component which is conditionally rendering the
<dialog className = "pick_up_dialog"/>
element based on whether a user has a reservation for the current day, according to data being received in an API call , "fetchReservations".
Unlike ReserveModal
and ProfileModal
, which are also <dialog/>
elements, but being returned in an imported component, the .pick_up_dialog <dialog/>
is getting conditionally rendered directly inside of the PortalHome component I've attached.
The transition animation from the dialog{}
declaration and other normal CSS settings are being applied to all three dialogs. But the dialog[open]::backdrop{}
settings are not being applied to the conditionally rendered .pick_up_dialog
.
Is there something about conditional rendering that changed the CSS access to an element in React?
My CSS is being imported in my App.js: import style from "./components/reserve.css";
When the dialog is open and I inspect it, there is no ::backdrop element rendered in the DOM.
What am I not understanding?11 Replies
take off the [open] and see what it does
dialog::backdrop {}
no difference, still working on the imported compomnent dialogs but not the conditionally rendered one
still workign meaning those two are getting the CSS applied while other one isn't, so nothiing's different
yea not sure... I'd just blame React 😂
it makes everything harder than it needs to be.
blast!
well, in case anyone else answers here or you care to look, heres also my full un-factored css
might help to use something like codesandbox or stackblitz so people can look at it in their browser
True, I'll post tmrw
Okay here's a sandbox:
https://codesandbox.io/p/sandbox/zen-shaw-qpqnt5?file=%2Fsrc%2Fstyles.css%3A11%2C1
'pickUpToday'
is the useState that has to be true in order to render the .conditionalRendDiag
dialog, which you can just manually set to true, false.
I wish I could say I perfectly replicated the issue from my react project, but the ::backdrop{}
pseudo-element in this code sandbox doesn't seem to have any effect on either the conditional or normally-rendered dialogs.
Maybe we could figure out why that would be first, get it to work, then test the difference that I was talking about..
In my react project, the conditionally-rendered dialog is not receiving the dialog::backdrop{background:"blue"}
CSS setting, and not showing any coloring in its "backdrop", while the other two non-conditional dialogs do reflect this CSS setting.I get a 404 on your sandbox, maybe it's set to private?
This may work: https://codesandbox.io/s/zen-shaw-qpqnt5?from-embed
nnall
CodeSandbox
zen-shaw-qpqnt5 - CodeSandbox
zen-shaw-qpqnt5 by nnall using react, react-dom, react-scripts
according to the docs it is recommended to use the open/close methods to show the dialog, not by toggling the open attribute
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog
this might be the reason why the ::backdrop is not showing up.
So add the dialog to the page and then call the open method on it
MDN Web Docs
: The Dialog element - HTML: HyperText Markup Language | MDN
The HTML element represents a modal or non-modal dialog box or other interactive component, such as a dismissible alert, inspector, or subwindow.
GitHub
bug: Dialog backdrop not working when controlled using
open
· Iss...What version of daisyUI are you using? v3.1.6 Describe your issue Thank you for building such an awesome library! I've been working with the Modal component and controlling it's state using...