Skip to content
Merged
Changes from all commits
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
20 changes: 9 additions & 11 deletions frontend/src/components/common/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,21 @@ export interface OurDialogTitleProps extends DialogTitleProps {
*/
export function DialogTitle(props: OurDialogTitleProps) {
const { children, focusTitle, buttons, disableTypography = false, id, ...other } = props;
const focusedRef = React.useCallback(
(node: HTMLElement | null) => {
if (node !== null && focusTitle) {
node.setAttribute('tabindex', '-1');
node.focus();
}
},
[focusTitle]
);

// Don't render heading if there's no content to avoid empty heading violations
if (!children && (!buttons || buttons.length === 0)) {
return null;
}

// eslint-disable-next-line react-hooks/rules-of-hooks
const focusedRef = React.useCallback((node: HTMLElement) => {
if (node !== null) {
if (focusTitle) {
node.setAttribute('tabindex', '-1');
node.focus();
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
<MuiDialogTitle style={{ display: 'flex' }} {...other}>
<Grid container justifyContent="space-between" alignItems="center">
Expand Down
Loading