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

DTRA-2055 +1 / Kate / [DTrader-V2] Trade page scrolling issue #17230

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@deriv-com/utils": "^0.0.36",
"@deriv-com/ui": "1.36.4",
"@deriv/api": "^1.0.0",
"@deriv-com/quill-ui": "1.16.20",
"@deriv-com/quill-ui": "1.17.0",
"@deriv/components": "^1.0.0",
"@deriv/hooks": "^1.0.0",
"@deriv/quill-icons": "1.23.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@datadog/browser-rum": "^5.11.0",
"@deriv-com/analytics": "1.14.0",
"@deriv-com/quill-tokens": "2.0.4",
"@deriv-com/quill-ui": "1.16.20",
"@deriv-com/quill-ui": "1.17.0",
"@deriv-com/translations": "1.3.9",
"@deriv-com/ui": "1.36.4",
"@deriv-com/utils": "^0.0.36",
Expand Down
2 changes: 1 addition & 1 deletion packages/trader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"dependencies": {
"@deriv-com/analytics": "1.14.0",
"@deriv-com/quill-tokens": "2.0.4",
"@deriv-com/quill-ui": "1.16.20",
"@deriv-com/quill-ui": "1.17.0",
"@deriv-com/utils": "^0.0.36",
"@deriv-com/ui": "1.36.4",
"@deriv/api-types": "1.0.172",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@ const Barrier = observer(({ is_minimized }: TDurationProps) => {
const [initialBarrierValue, setInitialBarrierValue] = React.useState('');
const isDays = duration_unit == 'd';

const onClose = (is_saved = false) => {
if (is_open) {
if (!is_saved) {
onChange({ target: { name: 'barrier_1', value: initialBarrierValue } });
const onClose = React.useCallback(
(is_saved = false) => {
if (is_open) {
if (!is_saved) {
onChange({ target: { name: 'barrier_1', value: initialBarrierValue } });
}
setV2ParamsInitialValues({ value: '', name: 'barrier_1' });
setIsOpen(false);
}
setV2ParamsInitialValues({ value: '', name: 'barrier_1' });
setIsOpen(false);
}
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[initialBarrierValue, is_open]
);

const barrier_carousel_pages = [
{
Expand All @@ -52,7 +56,13 @@ const Barrier = observer(({ is_minimized }: TDurationProps) => {
onClick={() => setIsOpen(true)}
className={clsx('trade-params__option', is_minimized && 'trade-params__option--minimized')}
/>
<ActionSheet.Root isOpen={is_open} onClose={() => onClose(false)} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
header={CarouselHeader}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ const Duration = observer(({ is_minimized }: TDurationProps) => {
return () => clearTimeout(start_duration);
}, [symbol, contract_type, duration_min_max, duration_units_list]);

const onClose = React.useCallback(() => setOpen(false), []);

const getInputValues = () => {
const formatted_date = end_date.toLocaleDateString('en-GB', {
day: 'numeric',
Expand Down Expand Up @@ -175,11 +177,10 @@ const Duration = observer(({ is_minimized }: TDurationProps) => {
/>
<ActionSheet.Root
isOpen={is_open}
onClose={() => {
setOpen(false);
}}
onClose={onClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<DurationActionSheetContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ const GrowthRate = observer(({ is_minimized }: TGrowthRateProps) => {
const handleGrowthRateChange = (rate: number) => {
onChange({ target: { name: 'growth_rate', value: rate } });
};
const onActionSheetClose = () => {
setIsOpen(false);
};
const onActionSheetClose = React.useCallback(() => setIsOpen(false), []);

const action_sheet_content = [
{
Expand Down Expand Up @@ -103,7 +101,13 @@ const GrowthRate = observer(({ is_minimized }: TGrowthRateProps) => {
value={`${getGrowthRatePercentage(growth_rate)}%`}
variant='fill'
/>
<ActionSheet.Root isOpen={is_open} onClose={onActionSheetClose} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onActionSheetClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
classname={clsx('growth-rate__carousel', is_small_screen && 'growth-rate__carousel--small')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const LastDigitPrediction = observer(({ is_minimized }: TLastDigitSelectorProps)
const onSaveButtonClick = () => {
if (last_digit !== selected_digit) handleLastDigitChange(selected_digit);
};
const onActionSheetClose = () => {
const onActionSheetClose = React.useCallback(() => {
setIsOpen(false);
setSelectedDigit(last_digit);
};
}, [last_digit]);

if (is_minimized)
return (
Expand All @@ -48,7 +48,13 @@ const LastDigitPrediction = observer(({ is_minimized }: TLastDigitSelectorProps)
className={clsx('trade-params__option', 'trade-params__option--minimized')}
onClick={() => setIsOpen(true)}
/>
<ActionSheet.Root isOpen={is_open} onClose={onActionSheetClose} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onActionSheetClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<ActionSheet.Header title={<Localize i18n_default_text='Last digit prediction' />} />
<ActionSheet.Content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const Multiplier = observer(({ is_minimized }: TMultiplierProps) => {
onChange({ target: { name: 'multiplier', value: multiplier } });
};

const onClose = React.useCallback(() => setIsOpen(false), []);

const action_sheet_content = [
{
id: 1,
Expand Down Expand Up @@ -73,9 +75,8 @@ const Multiplier = observer(({ is_minimized }: TMultiplierProps) => {
expandable={false}
isOpen={isOpen}
position='left'
onClose={() => {
setIsOpen(false);
}}
onClose={onClose}
shouldBlurOnClose={isOpen}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ const PayoutPerPoint = observer(({ is_minimized }: TPayoutPerPointProps) => {
];
const classname = clsx('trade-params__option', is_minimized && 'trade-params__option--minimized');

const onClose = React.useCallback(() => setIsOpen(false), []);

React.useEffect(() => {
const initial_payout_per_point = v2_params_initial_values?.payout_per_point;
if (initial_payout_per_point && payout_per_point !== initial_payout_per_point) {
Expand Down Expand Up @@ -95,7 +97,13 @@ const PayoutPerPoint = observer(({ is_minimized }: TPayoutPerPointProps) => {
variant='fill'
value={`${v2_params_initial_values?.payout_per_point ?? payout_per_point} ${currency_display_code}`}
/>
<ActionSheet.Root isOpen={is_open} onClose={() => setIsOpen(false)} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
classname={clsx(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const RiskManagement = observer(({ is_minimized }: TRiskManagementProps) => {
stop_loss,
} = useTraderStore();

const closeActionSheet = () => setIsOpen(false);
const closeActionSheet = React.useCallback(() => setIsOpen(false), []);
const getRiskManagementText = () => {
if (has_cancellation) return `DC: ${addUnit({ value: cancellation_duration, unit: localize('minutes') })}`;
if (has_take_profit && has_stop_loss)
Expand Down Expand Up @@ -84,7 +84,13 @@ const RiskManagement = observer(({ is_minimized }: TRiskManagementProps) => {
value={getRiskManagementText()}
variant='fill'
/>
<ActionSheet.Root isOpen={is_open} onClose={closeActionSheet} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={closeActionSheet}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
classname={clsx(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,20 @@ const Stake = observer(({ is_minimized }: TStakeProps) => {
onChange({ target: { name: 'amount', value: e.target.value } });
};

const onClose = (is_saved = false) => {
if (is_open) {
if (!is_saved) {
onChange({ target: { name: 'amount', value: v2_params_initial_values.stake } });
}
if (v2_params_initial_values.stake !== amount) {
setV2ParamsInitialValues({ value: amount, name: 'stake' });
const onClose = React.useCallback(
(is_saved = false) => {
if (is_open) {
if (!is_saved) {
onChange({ target: { name: 'amount', value: v2_params_initial_values.stake } });
}
if (v2_params_initial_values.stake !== amount) {
setV2ParamsInitialValues({ value: amount, name: 'stake' });
}
setIsOpen(false);
}
setIsOpen(false);
}
};
},
[v2_params_initial_values, is_open]
);

return (
<>
Expand All @@ -208,7 +211,13 @@ const Stake = observer(({ is_minimized }: TStakeProps) => {
className={clsx('trade-params__option', is_minimized && 'trade-params__option--minimized')}
status={stake_error && !is_open ? 'error' : undefined}
/>
<ActionSheet.Root isOpen={is_open} onClose={() => onClose(false)} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<ActionSheet.Header title={<Localize i18n_default_text='Stake' />} />
<ActionSheet.Content className='stake-content'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Strike = observer(({ is_minimized }: TStrikeProps) => {

const handleStrikeChange = (new_value: number | string) =>
onChange({ target: { name: 'barrier_1', value: new_value } });
const onClose = React.useCallback(() => setIsOpen(false), []);

const action_sheet_content = [
{
Expand Down Expand Up @@ -102,7 +103,13 @@ const Strike = observer(({ is_minimized }: TStrikeProps) => {
variant='fill'
value={barrier_1}
/>
<ActionSheet.Root isOpen={is_open} onClose={() => setIsOpen(false)} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
classname={clsx('strike__carousel', is_small_screen && 'strike__carousel--small')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const TakeProfit = observer(({ is_minimized }: TTakeProfitProps) => {

const [is_open, setIsOpen] = React.useState(false);

const onActionSheetClose = () => setIsOpen(false);
const onActionSheetClose = React.useCallback(() => setIsOpen(false), []);

const action_sheet_content = [
{
Expand Down Expand Up @@ -51,7 +51,13 @@ const TakeProfit = observer(({ is_minimized }: TTakeProfitProps) => {
variant='fill'
value={has_take_profit && take_profit ? `${take_profit} ${getCurrencyDisplayCode(currency)}` : '-'}
/>
<ActionSheet.Root isOpen={is_open} onClose={onActionSheetClose} position='left' expandable={false}>
<ActionSheet.Root
isOpen={is_open}
onClose={onActionSheetClose}
position='left'
expandable={false}
shouldBlurOnClose={is_open}
>
<ActionSheet.Portal shouldCloseOnDrag>
<Carousel
header={CarouselHeader}
Expand Down
Loading