Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui5-select): Change focus of options on keypress #3538

Merged
merged 6 commits into from
Aug 2, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix eslint errors
  • Loading branch information
IlianaB committed Jul 26, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit cbcc3046290fb67f2c88593a6ae6d4e36cd0b658
17 changes: 8 additions & 9 deletions packages/main/src/Select.js
Original file line number Diff line number Diff line change
@@ -469,15 +469,14 @@ class Select extends UI5Element {

_handleKeyboardNavigation(event) {
const sTypedCharacter = event.key;
let sText;

this._sTypedChars += sTypedCharacter;

// We check if we have more than one characters and they are all duplicate, we set the
// text to be the last input character (sTypedCharacter). If not, we set the text to be
// the whole input string.

sText = (/^(.)\1+$/i).test(this._sTypedChars) ? sTypedCharacter : this._sTypedChars;
const sText = (/^(.)\1+$/i).test(this._sTypedChars) ? sTypedCharacter : this._sTypedChars;

clearTimeout(this._iTypingTimeoutID);

@@ -491,17 +490,17 @@ class Select extends UI5Element {

_selectTypedItem(sText) {
const currentIndex = this._selectedIndex;
let oItemToSelect = this._searchNextItemByText(sText);
const oItemToSelect = this._searchNextItemByText(sText);

if (oItemToSelect) {
const nextIndex = this._getSelectedItemIndex(oItemToSelect);
if (oItemToSelect) {
const nextIndex = this._getSelectedItemIndex(oItemToSelect);

this._changeSelectedItem(this._selectedIndex, nextIndex);
this._changeSelectedItem(this._selectedIndex, nextIndex);

if (currentIndex !== this._selectedIndex) {
this.itemSelectionAnnounce();
}
if (currentIndex !== this._selectedIndex) {
this.itemSelectionAnnounce();
}
}
}

_searchNextItemByText(sText) {