Skip to content

Adds search by list item name to menuKeyUX#2

Merged
ai merged 8 commits intoai:mainfrom
VladBrok:add-menu-search
Feb 20, 2024
Merged

Adds search by list item name to menuKeyUX#2
ai merged 8 commits intoai:mainfrom
VladBrok:add-menu-search

Conversation

@VladBrok
Copy link
Copy Markdown
Contributor

Closes #1

menu.js Outdated
focus(event.target, items[items.length - 1])
} else {
let nextItem = Array.from(items).find(
item => item.textContent?.[0]?.toLowerCase() === event.key.toLowerCase()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We may need trim() to avoid finding anything by Space

menu.js Outdated
} else if (event.key === 'End') {
event.preventDefault()
focus(event.target, items[items.length - 1])
} else {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

We need not only to find by first letter, but also by some pattern of letters pressed with a small delay.

Like:

  1. a — looking for a
  2. b after 100ms — looking for ab
  3. c after 50ms — looking for abc
  4. d after 5000ms — looking for d

@VladBrok VladBrok changed the title Adds search by first character of items to menuKeyUX Adds search by list item name to menuKeyUX Feb 20, 2024
event.preventDefault()
focus(event.target, items[items.length - 1])
} else if (event.key.length === 1) {
let curTime = new Date().getTime()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Suggested change
let curTime = new Date().getTime()
let curTime = Date.now()

@ai ai merged commit 9e1132d into ai:main Feb 20, 2024
@ai
Copy link
Copy Markdown
Owner

ai commented Feb 20, 2024

Also check out how was possible to reduce 22 bytes 207d946

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add search to menuKeyUX

2 participants