Skip to content

Commit 116748d

Browse files
cevhericlaude
andcommitted
fix: close mobile drawer on VT navigation; re-run page scripts (copy buttons, stars) after transitions
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 47e65e3 commit 116748d

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/components/sections/DeploySection.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const summary = sortedCategories.map((c, i) => ({
108108
</section>
109109
</div>
110110

111-
<script>
111+
<script data-astro-rerun>
112112
import { formatStars } from '../../lib/github-stars';
113113

114114
async function refreshStars() {

src/components/sections/DockerComposeSection.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ const envGroups = [
180180
}
181181
</style>
182182

183-
<script>
183+
<script data-astro-rerun>
184184
document.querySelectorAll('.copy-btn').forEach((button) => {
185185
button.addEventListener('click', async () => {
186186
const code = button.getAttribute('data-code');

src/scripts/studio.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ function wireOnce() {
375375
document.addEventListener('click', onActionClick);
376376
window.addEventListener('keydown', onKeydown);
377377

378+
document.addEventListener('astro:before-swap', () => {
379+
// force-close the persisted drawer so it doesn't carry over to the next page
380+
const root = document.querySelector('[data-drawer-root]');
381+
const panel = document.querySelector('[data-drawer-panel]');
382+
panel?.classList.add('-translate-x-full');
383+
root?.classList.add('hidden');
384+
document.body.style.overflow = '';
385+
document.querySelector('[data-drawer-open]')?.setAttribute('aria-expanded', 'false');
386+
});
387+
378388
// Delegated input: explorer search filter + palette input
379389
document.addEventListener('input', (e) => {
380390
const target = e.target;

0 commit comments

Comments
 (0)