Skip to content
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

Prevent select element from flashing right before it's replaced #1782

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TASVideos/Pages/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<link rel="alternate" href="/publications.rss" type="application/rss+xml" title="TASVideos RSS Publication Feed">
<link rel="alternate" href="/wiki.rss" type="application/rss+xml" title="TASVideos RSS Wiki Feed">
<partial name="_MetaTags" />
<script>document.head.appendChild(document.createElement("style")).innerHTML = '.d-none-js { display: none !important; }';</script>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively:

Suggested change
<script>document.head.appendChild(document.createElement("style")).innerHTML = '.d-none-js { display: none !important; }';</script>
<!-- can move to main stylesheet --><style>:root.supports-js .d-none-js { display: none !important; }</style>
<script>document.documentElement.classList.add("supports-js");</script>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I can't test right now) Have you tested whether that prevents the flashing on repeated reloading on the usual browsers on desktop and mobile?
It may look the same, but I noticed adding a <style> blocks cached rendering better than adding a css class.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't (I also can't test atm)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are all a single taghelper now if that helps with a better strategy. But can we close this? we dont' want this hacky approach

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm going to close this PR. This seems to need a different approach altogether.

</head>
<body>
<nav id="banner" class="navbar navbar-expand-md navbar-dark mb-4">
Expand Down
6 changes: 3 additions & 3 deletions TASVideos/Pages/Submissions/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
<row>
<div class="col-12 col-md-6">
<label asp-for="Search.StatusFilter" class="form-control-label"></label>
<select asp-for="Search.StatusFilter" asp-items="Model.AvailableStatuses" class="form-control"></select>
<select asp-for="Search.StatusFilter" asp-items="Model.AvailableStatuses" class="form-control d-none-js"></select>
</div>
<div class="col-12 col-md-6">
<label asp-for="Search.Years" class="form-control-label"></label>
<select asp-for="Search.Years" asp-items="selectAvailableYears" multiple class="form-control"></select>
<select asp-for="Search.Years" asp-items="selectAvailableYears" multiple class="form-control d-none-js"></select>
<label asp-for="Search.User" class="form-control-label"></label>
<input autocomplete="off" asp-for="Search.User" type="text" list="@Html.IdFor(m => m.Search.User)-autocomplete" class="form-control" />

<label asp-for="Search.System" class="form-control-label"></label>
<select asp-for="Search.System" asp-items="Model.SystemList" class="form-control"></select>
<select asp-for="Search.System" asp-items="Model.SystemList" class="form-control d-none-js"></select>
</div>
</row>
<button type="submit" class="btn btn-secondary mt-1"><i class="fa fa-filter"></i> Filter</button>
Expand Down
Loading