Skip to content

Commit b41e166

Browse files
authored
[Blazor] Some of the default UI styling is not accessible in dark mode (#57142)
* Isolate the reconnect UI into its own shadow DOM to avoid accidental styling.
1 parent 3f72dd2 commit b41e166

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

eng/Npm.Workspace.nodeproj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929

3030
<Target Name="Build">
3131
<PropertyGroup>
32-
<PackageVersion>$(VersionPrefix)$(VersionSuffix)</PackageVersion>
32+
<PackageVersion>$(VersionPrefix)</PackageVersion>
33+
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
3334
</PropertyGroup>
3435
<MakeDir Directories="$(IntermediateOutputPath)" Condition="!Exists('$(IntermediateOutputPath)')" />
3536

3637
<Message Text="Building NPM packages..." Importance="high" />
3738

38-
<Exec
39+
<Exec Condition="'$(ContinuousIntegrationBuild)' == 'true'"
3940
Command="node $(MSBuildThisFileDirectory)scripts/npm/pack-workspace.mjs --update-versions $(RepoRoot)package.json $(PackageVersion) $(PackageOutputPath) $(IntermediateOutputPath)"
4041
EnvironmentVariables="$(_NpmAdditionalEnvironmentVariables)" />
4142

@@ -52,7 +53,8 @@
5253

5354
<Target Name="Pack">
5455
<PropertyGroup>
55-
<PackageVersion>$(VersionPrefix)$(VersionSuffix)</PackageVersion>
56+
<PackageVersion>$(VersionPrefix)</PackageVersion>
57+
<PackageVersion Condition="'$(VersionSuffix)' != ''">$(VersionPrefix)-$(VersionSuffix)</PackageVersion>
5658
</PropertyGroup>
5759
<Message Text="Packing NPM packages..." Importance="high" />
5860
<MakeDir Directories="$(PackageOutputPath)" Condition="!Exists('$(PackageOutputPath)')" />

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/src/Platform/Circuits/DefaultReconnectDisplay.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
2020

2121
overlay: HTMLDivElement;
2222

23+
host: HTMLDivElement;
24+
2325
dialog: HTMLDivElement;
2426

2527
rejoiningAnimation: HTMLDivElement;
@@ -36,10 +38,15 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
3638

3739
this.overlay = this.document.createElement('div');
3840
this.overlay.className = DefaultReconnectDisplay.ReconnectOverlayClassName;
39-
this.overlay.id = dialogId;
4041

41-
this.dialog = this.document.createElement('div');
42+
this.host = this.document.createElement('div');
43+
this.host.id = dialogId;
44+
45+
const shadow = this.host.attachShadow({ mode: 'open' });
46+
this.dialog = document.createElement('div');
4247
this.dialog.className = DefaultReconnectDisplay.ReconnectDialogClassName;
48+
shadow.appendChild(this.style);
49+
shadow.appendChild(this.overlay);
4350

4451
this.rejoiningAnimation = document.createElement('div');
4552
this.rejoiningAnimation.className = DefaultReconnectDisplay.RejoiningAnimationClassName;
@@ -71,18 +78,14 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
7178
}
7279

7380
show(): void {
74-
if (!this.document.contains(this.overlay)) {
75-
this.document.body.appendChild(this.overlay);
76-
}
77-
78-
if (!this.document.contains(this.style)) {
79-
this.document.body.appendChild(this.style);
81+
if (!this.document.contains(this.host)) {
82+
this.document.body.appendChild(this.host);
8083
}
8184

8285
this.reloadButton.style.display = 'none';
8386
this.rejoiningAnimation.style.display = 'block';
8487
this.status.innerHTML = 'Rejoining the server...';
85-
this.overlay.style.display = 'block';
88+
this.host.style.display = 'block';
8689
this.overlay.classList.add(DefaultReconnectDisplay.ReconnectVisibleClassName);
8790
}
8891

@@ -96,7 +99,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
9699
}
97100

98101
hide(): void {
99-
this.overlay.style.display = 'none';
102+
this.host.style.display = 'none';
100103
this.overlay.classList.remove(DefaultReconnectDisplay.ReconnectVisibleClassName);
101104
}
102105

0 commit comments

Comments
 (0)