Gin Toolbar should not extend drupal/dialog unconditionally
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3591121. -->
Reported by: [fmb](https://www.drupal.org/user/619092)
>>>
<h3 id="summary-problem-motivation">Problem/Motivation</h3>
<p>Gin Toolbar "extends" the core/drupal.dialog library by adding Claro and Gin dependencies in gin_toolbar_library_info_alter():</p>
<div class="codeblock">
<pre><span style="color: #000000"><span style="color: #0000BB"><?php<br></span><span style="color: #FF8000">/**<br> * Attach libraries.<br> */<br></span><span style="color: #007700">function </span><span style="color: #0000BB">gin_toolbar_library_info_alter</span><span style="color: #007700">(&</span><span style="color: #0000BB">$libraries</span><span style="color: #007700">, </span><span style="color: #0000BB">$extension</span><span style="color: #007700">) {<br> if (</span><span style="color: #0000BB">$extension </span><span style="color: #007700">== </span><span style="color: #DD0000">'core' </span><span style="color: #007700">&& isset(</span><span style="color: #0000BB">$libraries</span><span style="color: #007700">[</span><span style="color: #DD0000">'drupal.dialog'</span><span style="color: #007700">])) {<br> </span><span style="color: #0000BB">$libraries</span><span style="color: #007700">[</span><span style="color: #DD0000">'drupal.dialog'</span><span style="color: #007700">][</span><span style="color: #DD0000">'dependencies'</span><span style="color: #007700">][] = </span><span style="color: #DD0000">'claro/claro.drupal.dialog'</span><span style="color: #007700">;<br> </span><span style="color: #0000BB">$libraries</span><span style="color: #007700">[</span><span style="color: #DD0000">'drupal.dialog'</span><span style="color: #007700">][</span><span style="color: #DD0000">'dependencies'</span><span style="color: #007700">][] = </span><span style="color: #DD0000">'gin/dialog'</span><span style="color: #007700">;<br> }<br></span><span style="color: #0000BB">?></span></span></pre></div>
<p>The way this is implemented, claro/claro.drupal.dialog and gin/dialog will be attached even for anonymous users who have nothing to do with admin themes and should not load Gin and Claro assets at all. This actually causes display issues, as the included CSS files rely on CSS variables which are not set, so a modal dialog ends up being rendered with no background, for instance.</p>
<h4 id="summary-steps-reproduce">Steps to reproduce</h4>
<ol>
<li>Use the <a href="https://www.drupal.org/docs/develop/drupal-apis/ajax-api/ajax-dialog-boxes">Ajax dialog API</a> to open links in a modal dialog on a Drupal website where the Gin Toolbar module is enabled.</li>
<li>The modal dialog should be OK for admin users.</li>
<li>It likely will not for anonymous users, as some CSS files will be loaded without setting the corresponding CSS variables (please see attached screenshots).</li>
</ol>
<h3 id="summary-proposed-resolution">Proposed resolution</h3>
<p>Figure out a way to load these libraries only for users who can access to the admin theme.</p>
issue