mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
refactor(shortcuts): use data-testid selectors for reliable targeting
Add data-testid="nav-settings" to the Settings menu item in
AccountSettings so the open-settings shortcut no longer relies on
fragile text-content matching ('Settings' but not 'Keyboard').
This commit is contained in:
parent
4b50012c32
commit
af42d9d9fd
2 changed files with 7 additions and 8 deletions
|
|
@ -89,7 +89,11 @@ function AccountSettings({ collapsed = false }: { collapsed?: boolean }) {
|
|||
<Keyboard className="icon-md" aria-hidden="true" />
|
||||
{localize('com_shortcut_keyboard_shortcuts')}
|
||||
</Menu.MenuItem>
|
||||
<Menu.MenuItem onClick={() => setShowSettings(true)} className="select-item text-sm">
|
||||
<Menu.MenuItem
|
||||
onClick={() => setShowSettings(true)}
|
||||
className="select-item text-sm"
|
||||
data-testid="nav-settings"
|
||||
>
|
||||
<GearIcon className="icon-md" aria-hidden="true" />
|
||||
{localize('com_nav_settings')}
|
||||
</Menu.MenuItem>
|
||||
|
|
|
|||
|
|
@ -269,13 +269,8 @@ export default function useKeyboardShortcuts() {
|
|||
}
|
||||
btn.click();
|
||||
setTimeout(() => {
|
||||
const items = document.querySelectorAll<HTMLElement>('[role="menuitem"]');
|
||||
for (const item of items) {
|
||||
if (item.textContent?.includes('Settings') && !item.textContent?.includes('Keyboard')) {
|
||||
item.click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
const settingsItem = document.querySelector<HTMLElement>('[data-testid="nav-settings"]');
|
||||
settingsItem?.click();
|
||||
}, 150);
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue