-
Notifications
You must be signed in to change notification settings - Fork 10k
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
[Blazor] Enable custom text in the new (.Net 9.0) reconnect dialog #57453
Comments
@dgoldm thanks for contacting us. We don't offer customization of the built-in UI bits other than you providing your own UI. With that said, you should be able to detect when the element is made visible on to the page using a https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver |
Thanks @javiercn. Understanding that it now requires javascript, it would be great if MS could provide information on how to create my own UI and hook into the circuit events, |
@dgoldm You can still use the option that you mention, but you won't get the styles, etc. of the new reconnect dialog. The built-in reconnect UI has never been extensible by other means than you providing your own markup, at which point we simply set some classes and some text on the markup you provide. In the future we likely want to move this UI into the template itself, there's no need for this UI to be hardcoded inside blazor and only creates problems like this. If you want to replicate the UI within your app, you can grab the styles and HTML from our default one from here: |
@javiercn I'm not interested in the styles, only the functionality, namely to display different messages corresponding to the current state of the reconnection mechanism. But for that I would have to be able to implement the various callbacks of ReconnectDisplay. That doesn't seem to be in the scope of the snippets you marked. Anyway in the meantime I've managed to implement the MutationObserver workaround that you suggested. Add this to App.razor:
|
Hi there, not sure this goes here, however I had an issue with text color. I suspect my theming (using mudblazor) was is inverting color of the paragraph style globally. So perhaps the new .net9 reconnect dialog should force black color in it's default style? #components-reconnect-modal { For me, that made the text visible again when user's chose dark mode, |
Hi @raphadesa, |
Hi @dgoldm #components-reconnect-modal p {
color: black !important;
} |
Based on your solution @dgoldm and with some modifications, I was finally able to display a black color. Here's my code if it helps anyone. const observer = new MutationObserver(() => {
let dialog = document.getElementById('components-reconnect-modal');
if (dialog) {
var shadowRoot = dialog.shadowRoot;
if (shadowRoot) {
var paragraph = shadowRoot.querySelector('p');
if (paragraph) {
paragraph.style.color = 'black';
paragraph.innerHTML = '{your custom text}';
}
}
};
});
observer.observe(document.body, { childList: true, subtree: true }); |
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
The new reconnect dialog, displayed by Blazor when the browser loses connection with the server is a wonderful improvement, and I'm tempted to upgrade my project, which is used in production, to .Net 9.0 preview for this reason alone.
The problem is that I need to display the text in languages other than English.
As far as I can see the English text is hard-coded, e.g.:
aspnetcore/src/Components/Web.JS/src/Platform/Circuits/DefaultReconnectDisplay.ts
Line 94 in d65f5c4
Describe the solution you'd like
Could you provide a way to customize the text?
Additional context
No response
The text was updated successfully, but these errors were encountered: