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

fix(Select): prevent footer clicks from toggling #7193

Merged
merged 1 commit into from Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/react-core/src/components/Select/SelectToggle.tsx
Expand Up @@ -100,11 +100,14 @@ export class SelectToggle extends React.Component<SelectToggleProps> {
}

onDocClick = (event: Event) => {
const { parentRef, menuRef, isOpen, onToggle, onClose } = this.props;
const { parentRef, menuRef, footerRef, isOpen, onToggle, onClose } = this.props;
const clickedOnToggle = parentRef && parentRef.current && parentRef.current.contains(event.target as Node);
const clickedWithinMenu =
menuRef && menuRef.current && menuRef.current.contains && menuRef.current.contains(event.target as Node);
if (isOpen && !(clickedOnToggle || clickedWithinMenu)) {
const clickedWithinFooter =
footerRef && footerRef.current && footerRef.current.contains && footerRef.current.contains(event.target as Node);

if (isOpen && !(clickedOnToggle || clickedWithinMenu || clickedWithinFooter)) {
onToggle(false, event);
onClose();
}
Expand Down