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

WALL-2622/chore: close the modals on escape key by default #11464

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { WalletText } from '../WalletText';
import './ModalStepWrapper.scss';

type TModalStepWrapperProps = {
closeOnEscape?: boolean;
disableOnEscapeClick?: boolean;
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
renderFooter?: () => ReactNode;
shouldFixedFooter?: boolean;
shouldHideHeader?: boolean;
Expand All @@ -16,7 +16,7 @@ type TModalStepWrapperProps = {

const ModalStepWrapper: FC<PropsWithChildren<TModalStepWrapperProps>> = ({
children,
closeOnEscape = false,
disableOnEscapeClick = false,
renderFooter,
shouldFixedFooter = true,
shouldHideHeader = false,
Expand All @@ -27,7 +27,7 @@ const ModalStepWrapper: FC<PropsWithChildren<TModalStepWrapperProps>> = ({
const fixedFooter = shouldFixedFooter && hasRenderFooter;

useEventListener('keydown', (event: KeyboardEvent) => {
if (closeOnEscape && event.key === 'Escape') {
if (!disableOnEscapeClick && event.key === 'Escape') {
hide();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { useModal } from '../../ModalProvider';
import './ModalWrapper.scss';

type TProps = {
closeOnEscape?: boolean;
disableOnEscapeClick?: boolean;
hideCloseButton?: boolean;
};

const ModalWrapper: FC<React.PropsWithChildren<TProps>> = ({
children,
closeOnEscape = false,
thisyahlen-deriv marked this conversation as resolved.
Show resolved Hide resolved
disableOnEscapeClick = false,
hideCloseButton = false,
}) => {
const { hide } = useModal();

useEventListener('keydown', (event: KeyboardEvent) => {
if (closeOnEscape && event.key === 'Escape') {
if (!disableOnEscapeClick && event.key === 'Escape') {
hide();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const DerivAppsGetAccount: React.FC = () => {
const openSuccessModal = useCallback(() => {
show(
<ModalStepWrapper
closeOnEscape
renderFooter={isDesktop ? undefined : () => <DerivAppsSuccessFooter />}
shouldHideHeader={isDesktop}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const ModalTradeWrapper: FC<PropsWithChildren<TModalTradeWrapper>> = ({ children

return (
<ModalStepWrapper
closeOnEscape
renderFooter={() => {
return (
<div className='wallets-modal-trade-wrapper__footer'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const JurisdictionModal = () => {
return (
<DynamicLeverageContext.Provider value={{ isDynamicLeverageVisible, toggleDynamicLeverage }}>
<ModalStepWrapper
closeOnEscape
renderFooter={modalFooter}
shouldHideHeader={isDynamicLeverageVisible}
title={jurisdictionTitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const MT5AccountTypeModal = () => {

return (
<ModalStepWrapper
closeOnEscape
renderFooter={() => (
<WalletButton
disabled={!selectedMarketType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const MT5PasswordModal: React.FC<TProps> = ({ marketType, platform }) => {
}

return (
<ModalWrapper closeOnEscape hideCloseButton={isSuccess}>
<ModalWrapper hideCloseButton={isSuccess}>
{isSuccess && (
<CFDSuccess
description={`You can now start practicing trading with your ${marketTypeTitle} ${
Expand Down
Loading