Skip to content

Commit

Permalink
Rename shouldpreventScrollOnItemFocus
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewgdewar committed Oct 9, 2024
1 parent f680242 commit 49129ed
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions packages/react-core/src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface DropdownProps extends MenuProps, OUIAProps {
/** @beta Flag indicating the first menu item should be focused after opening the dropdown. */
shouldFocusFirstItemOnOpen?: boolean;
/** Flag indicating if scroll on focus of the first menu item should occur. */
preventScrollOnItemFocus?: boolean;
shouldpreventScrollOnItemFocus?: boolean;
}

const DropdownBase: React.FunctionComponent<DropdownProps> = ({
Expand All @@ -94,7 +94,7 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
menuHeight,
maxMenuHeight,
shouldFocusFirstItemOnOpen = true,
preventScrollOnItemFocus = true,
shouldpreventScrollOnItemFocus = true,
...props
}: DropdownProps) => {
const localMenuRef = React.useRef<HTMLDivElement>();
Expand All @@ -117,7 +117,7 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
) {
if (onOpenChangeKeys.includes(event.key)) {
onOpenChange(false);
toggleRef.current?.focus({ preventScroll: preventScrollOnItemFocus });
toggleRef.current?.focus({ preventScroll: shouldpreventScrollOnItemFocus });
}
}
};
Expand All @@ -128,7 +128,7 @@ const DropdownBase: React.FunctionComponent<DropdownProps> = ({
const firstElement = menuRef?.current?.querySelector(
'li button:not(:disabled),li input:not(:disabled),li a:not([aria-disabled="true"])'
);
firstElement && (firstElement as HTMLElement).focus({ preventScroll: preventScrollOnItemFocus });
firstElement && (firstElement as HTMLElement).focus({ preventScroll: shouldpreventScrollOnItemFocus });
}

// If the event is not on the toggle and onOpenChange callback is provided, close the menu
Expand Down
8 changes: 4 additions & 4 deletions packages/react-core/src/components/Menu/MenuContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface MenuContainerProps {
/** Additional properties to pass to the Popper */
popperProps?: MenuPopperProps;
/** Flag indicating if scroll on focus of the first menu item should occur. */
preventScrollOnItemFocus?: boolean;
shouldpreventScrollOnItemFocus?: boolean;
}

/**
Expand All @@ -55,7 +55,7 @@ export const MenuContainer: React.FunctionComponent<MenuContainerProps> = ({
zIndex = 9999,
popperProps,
onOpenChangeKeys = ['Escape', 'Tab'],
preventScrollOnItemFocus = true
shouldpreventScrollOnItemFocus = true
}: MenuContainerProps) => {
React.useEffect(() => {
const handleMenuKeys = (event: KeyboardEvent) => {
Expand All @@ -66,7 +66,7 @@ export const MenuContainer: React.FunctionComponent<MenuContainerProps> = ({
) {
if (onOpenChangeKeys.includes(event.key)) {
onOpenChange(false);
toggleRef.current?.focus({ preventScroll: preventScrollOnItemFocus });
toggleRef.current?.focus({ preventScroll: shouldpreventScrollOnItemFocus });
}
}
};
Expand All @@ -77,7 +77,7 @@ export const MenuContainer: React.FunctionComponent<MenuContainerProps> = ({
const firstElement = menuRef?.current?.querySelector(
'li button:not(:disabled),li input:not(:disabled),li a:not([aria-disabled="true"])'
);
firstElement && (firstElement as HTMLElement).focus({ preventScroll: preventScrollOnItemFocus });
firstElement && (firstElement as HTMLElement).focus({ preventScroll: shouldpreventScrollOnItemFocus });
}

// If the event is not on the toggle and onOpenChange callback is provided, close the menu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface PaginationOptionsMenuProps extends React.HTMLProps<HTMLDivEleme
/** @beta The container to append the pagination options menu to. Overrides the containerRef prop. */
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
/** Flag indicating if scroll on focus of the first menu item should occur. */
preventScrollOnItemFocus?: boolean;
shouldpreventScrollOnItemFocus?: boolean;
}

export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMenuProps> = ({
Expand All @@ -83,7 +83,7 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
onPerPageSelect = () => null as any,
containerRef,
appendTo,
preventScrollOnItemFocus = true
shouldpreventScrollOnItemFocus = true
}: PaginationOptionsMenuProps) => {
const [isOpen, setIsOpen] = React.useState(false);
const toggleRef = React.useRef<HTMLButtonElement>(null);
Expand Down Expand Up @@ -126,7 +126,7 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
) {
if (event.key === 'Escape' || event.key === 'Tab') {
setIsOpen(false);
toggleRef.current?.focus({ preventScroll: preventScrollOnItemFocus });
toggleRef.current?.focus({ preventScroll: shouldpreventScrollOnItemFocus });
}
}
};
Expand All @@ -135,7 +135,7 @@ export const PaginationOptionsMenu: React.FunctionComponent<PaginationOptionsMen
// Focus the first non-disabled menu item on toggle 'click'
if (isOpen && toggleRef.current?.contains(event.target as Node)) {
const firstElement = menuRef?.current?.querySelector('li button:not(:disabled)');
firstElement && (firstElement as HTMLElement).focus({ preventScroll: preventScrollOnItemFocus });
firstElement && (firstElement as HTMLElement).focus({ preventScroll: shouldpreventScrollOnItemFocus });
}

// If the event is not on the toggle, close the menu
Expand Down
8 changes: 4 additions & 4 deletions packages/react-core/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface SelectProps extends MenuProps, OUIAProps {
/** Indicates if the select menu should be scrollable */
isScrollable?: boolean;
/** Flag indicating if scroll on focus of the first menu item should occur. */
preventScrollOnItemFocus?: boolean;
shouldpreventScrollOnItemFocus?: boolean;
}

const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
Expand All @@ -101,7 +101,7 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
menuHeight,
maxMenuHeight,
isScrollable,
preventScrollOnItemFocus = true,
shouldpreventScrollOnItemFocus = true,
...props
}: SelectProps & OUIAProps) => {
const localMenuRef = React.useRef<HTMLDivElement>();
Expand All @@ -124,7 +124,7 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
if (onOpenChangeKeys.includes(event.key)) {
event.preventDefault();
onOpenChange(false);
toggleRef.current?.focus({ preventScroll: preventScrollOnItemFocus });
toggleRef.current?.focus({ preventScroll: shouldpreventScrollOnItemFocus });
}
}
};
Expand All @@ -133,7 +133,7 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
// toggle was opened, focus on first menu item
if (isOpen && shouldFocusFirstItemOnOpen && toggleRef.current?.contains(event.target as Node)) {
const firstElement = menuRef?.current?.querySelector('li button:not(:disabled),li input:not(:disabled)');
firstElement && (firstElement as HTMLElement).focus({ preventScroll: preventScrollOnItemFocus });
firstElement && (firstElement as HTMLElement).focus({ preventScroll: shouldpreventScrollOnItemFocus });
}

// If the event is not on the toggle and onOpenChange callback is provided, close the menu
Expand Down
6 changes: 3 additions & 3 deletions packages/react-core/src/components/Tabs/OverflowTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface OverflowTabProps extends React.HTMLProps<HTMLLIElement> {
/** z-index of the overflow tab */
zIndex?: number;
/** Flag indicating if scroll on focus of the first menu item should occur. */
preventScrollOnItemFocus?: boolean;
shouldpreventScrollOnItemFocus?: boolean;
}

export const OverflowTab: React.FunctionComponent<OverflowTabProps> = ({
Expand All @@ -32,7 +32,7 @@ export const OverflowTab: React.FunctionComponent<OverflowTabProps> = ({
defaultTitleText = 'More',
toggleAriaLabel,
zIndex = 9999,
preventScrollOnItemFocus = true,
shouldpreventScrollOnItemFocus = true,
...props
}: OverflowTabProps) => {
const menuRef = React.useRef<HTMLDivElement>();
Expand Down Expand Up @@ -81,7 +81,7 @@ export const OverflowTab: React.FunctionComponent<OverflowTabProps> = ({

if (menuRef?.current) {
const firstElement = menuRef.current.querySelector('li > button,input:not(:disabled)');
firstElement && (firstElement as HTMLElement).focus({ preventScroll: preventScrollOnItemFocus });
firstElement && (firstElement as HTMLElement).focus({ preventScroll: shouldpreventScrollOnItemFocus });
}
};

Expand Down

0 comments on commit 49129ed

Please sign in to comment.