Skip to content

Commit

Permalink
fix modal body block, add locales for modal close button
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaMate committed Apr 4, 2024
1 parent 4066636 commit c7face6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"toggle_theme_image_alt_button": "Theme image",
"not_found_title": "Not found",
"not_found_description": "The resource you requested has been deleted or moved to another location",
"error_boundary_title": "Something went wrong"
"error_boundary_title": "Something went wrong",
"close_modal_window_button": "Close modal window"
}
3 changes: 2 additions & 1 deletion public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"toggle_theme_image_alt_button": "Картинка темы",
"not_found_title": "Не найдено",
"not_found_description": "Запрашиваемый вами ресурс удален или перенесен в другое место",
"error_boundary_title": "Что-то пошло не так"
"error_boundary_title": "Что-то пошло не так",
"close_modal_window_button": "Закрыть модальное окно"
}
4 changes: 3 additions & 1 deletion src/components/shared/ui/modal/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
useModalInnerManager,
} from '@/components/shared/ui/modal/Modal/hooks/useModalInnerManager.ts';
import Button from '@/components/shared/ui/buttons/Button/Button.tsx';
import { useTranslation } from 'react-i18next';


export type ModalProps =
Expand All @@ -19,6 +20,7 @@ export type ModalProps =

const Modal: React.FC<ModalProps> = (props) => {
const { className, controller, ...other } = props;
const { t } = useTranslation();
const { placeRef, modalRef } = useModalInnerManager(controller.opened);

return (
Expand All @@ -30,7 +32,7 @@ const Modal: React.FC<ModalProps> = (props) => {
className={ classNames(css.container, { [css.hidden]: !controller.opened }, []) }
ref={ modalRef }
>
<Button aria-label="Закрыть модальное окно"
<Button aria-label={ t('close_modal_window_button') }
className={ css.closeButton }
onClick={ () => controller.setOpened(false) }
>X</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const useModalInnerManager = function (opened: boolean) {
}

// Unblock body scroll
document.body.classList.add('block-scroll');
document.body.classList.remove('block-scroll');

// Set focus on previousFocus
previousFocus.current?.focus();
Expand Down

0 comments on commit c7face6

Please sign in to comment.