Skip to content

Commit 370af3d

Browse files
author
User
committed
UI Improvement: Add neon glow effect and auto-scroll to active tab
1 parent 07a8b25 commit 370af3d

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/menulist-tab.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ export class MenulistTabElement extends HTMLElement {
143143

144144
if (tab.active) {
145145
this.tabButton.classList.add("active");
146+
// Scroll to center with a small delay to avoid initial render conflicts
147+
setTimeout(() => this.scrollIntoViewIfActive(), 100);
146148
}
147149

148150
// https://qiita.com/piroor/items/44ccbc2ee918bc88c3ea
@@ -161,6 +163,14 @@ export class MenulistTabElement extends HTMLElement {
161163
this.tabMainElement.style.borderColor = displayedContainer.colorCode;
162164
}
163165

166+
private scrollIntoViewIfActive(): void {
167+
// Scroll the active tab into view at the center of the sidebar
168+
// Using requestAnimationFrame to ensure DOM is ready
169+
requestAnimationFrame(() => {
170+
this.scrollIntoView({ behavior: 'smooth', block: 'center' });
171+
});
172+
}
173+
164174
private getShadowElement(id: string): HTMLElement {
165175
const element = this.shadowRoot?.getElementById(id);
166176
if (!element) {

static/css/components/menulist-tab.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ button:focus {
146146

147147
#tab-button.active {
148148
font-weight: bold;
149+
box-shadow: inset 0 0 8px 2px rgba(0, 150, 255, 0.4);
149150
}
150151

151152
#tab-button:hover, #tab-button:focus {

0 commit comments

Comments
 (0)