Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanu1 committed Nov 24, 2021
1 parent 0ca09fc commit da616ae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sample-app/src/components/DropdownSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface DropdownSectionProps {
options: Option[],
optionIdPrefix: string,
onFocusChange?: (value: string, focusedOptionId: string) => void,
onLeaveSectionFocus?: (focusNext: boolean) => void,
onLeaveSectionFocus?: (pastEnd: boolean) => void,
onClickOption?: (option: Option, optionIndex: number) => void,
label?: string,
cssClasses: {
Expand Down
14 changes: 9 additions & 5 deletions sample-app/src/components/InputDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,15 @@ export default function InputDropdown({

const numSections = childrenWithProps.length;

function onLeaveSectionFocus(focusNext: boolean) {
if (focusedSectionIndex === undefined && focusNext) {
/**
* Handles changing which section should become focused when focus leaves the currently-focused section.
* @param pastEnd Whether the section focus left from the end or the beginning of the section.
*/
function onLeaveSectionFocus(pastEnd: boolean) {
if (focusedSectionIndex === undefined && pastEnd) {
dispatch({ type: 'FocusSection', newIndex: 0 });
} else if (focusedSectionIndex !== undefined) {
let newSectionIndex: number | undefined = focusNext
let newSectionIndex: number | undefined = pastEnd
? focusedSectionIndex + 1
: focusedSectionIndex - 1;
if (newSectionIndex < 0) {
Expand Down Expand Up @@ -151,7 +155,7 @@ export default function InputDropdown({
}
});

function onKeyDown(evt: KeyboardEvent<HTMLInputElement>) {
function handleInputElementKeydown(evt: KeyboardEvent<HTMLInputElement>) {
if (evt.key === 'Enter') {
onInputChange(inputValue);
onSubmit(inputValue);
Expand Down Expand Up @@ -180,7 +184,7 @@ export default function InputDropdown({
setScreenReaderKey(screenReaderKey + 1);
}
}}
onKeyDown={onKeyDown}
onKeyDown={handleInputElementKeydown}
value={inputValue}
ref={inputRef}
aria-describedby={screenReaderInstructionsId}
Expand Down

0 comments on commit da616ae

Please sign in to comment.