Skip to content

Commit

Permalink
fix: #7035, Dropdown: Remove unused depreciated code
Browse files Browse the repository at this point in the history
  • Loading branch information
ANTONA09 committed Aug 13, 2024
1 parent 4da5a7b commit 9abd784
Showing 1 changed file with 0 additions and 75 deletions.
75 changes: 0 additions & 75 deletions components/lib/dropdown/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const Dropdown = React.memo(
const virtualScrollerRef = React.useRef(null);
const searchTimeout = React.useRef(null);
const searchValue = React.useRef(null);
const currentSearchChar = React.useRef(null);
const isLazy = props.virtualScrollerOptions && props.virtualScrollerOptions.lazy;
const hasFilter = ObjectUtils.isNotEmpty(filterState);
const appendTo = props.appendTo || (context && context.appendTo) || PrimeReact.appendTo;
Expand Down Expand Up @@ -582,80 +581,6 @@ export const Dropdown = React.memo(
return isOptionDisabled(option) ? findPrevOption(i) : option;
};

const search = (event) => {
if (searchTimeout.current) {
clearTimeout(searchTimeout.current);
}

if (event.ctrlKey || event.metaKey || event.altKey) {
// ignore meta combinations like CTRL+F for browser search
return;
}

const char = event.key;

if (char.length !== 1 || props.editable) {
// only single character keys matter for searching
return;
}

if (currentSearchChar.current === char) {
searchValue.current = char;
} else {
searchValue.current = searchValue.current ? searchValue.current + char : char;
}

currentSearchChar.current = char;

if (searchValue.current) {
const searchIndex = getSelectedOptionIndex();

setFocusedOptionIndex(props.optionGroupLabel ? searchIndex : searchIndex + 1);
}

searchTimeout.current = setTimeout(() => {
searchValue.current = null;
}, 250);
};

const searchOptionInGroup = (index) => {
const searchIndex = index === -1 ? { group: 0, option: -1 } : index;

for (let i = searchIndex.group; i < visibleOptions.length; i++) {
let groupOptions = getOptionGroupChildren(visibleOptions[i]);

for (let j = searchIndex.group === i ? searchIndex.option + 1 : 0; j < groupOptions.length; j++) {
if (matchesSearchValue(groupOptions[j])) {
return groupOptions[j];
}
}
}

for (let i = 0; i <= searchIndex.group; i++) {
let groupOptions = getOptionGroupChildren(visibleOptions[i]);

for (let j = 0; j < (searchIndex.group === i ? searchIndex.option : groupOptions.length); j++) {
if (matchesSearchValue(groupOptions[j])) {
return groupOptions[j];
}
}
}

return null;
};

const matchesSearchValue = (option) => {
let label = getOptionLabel(option);

if (!label) {
return false;
}

label = label.toLocaleLowerCase(props.filterLocale);

return label.startsWith(searchValue.current.toLocaleLowerCase(props.filterLocale));
};

const onEditableInputChange = (event) => {
!overlayVisibleState && show();
let searchIndex = null;
Expand Down

0 comments on commit 9abd784

Please sign in to comment.