From 5380737133484f52fa1eecf15cb6f207de366224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Miko=C5=82ajczyk?= Date: Wed, 20 Mar 2024 13:31:24 +0100 Subject: [PATCH 1/4] oct-1478: allocation slider thumb can not be moved outside the box --- client/src/components/ui/Slider/Slider.tsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/client/src/components/ui/Slider/Slider.tsx b/client/src/components/ui/Slider/Slider.tsx index 0ecbc2affb..4e058324b7 100644 --- a/client/src/components/ui/Slider/Slider.tsx +++ b/client/src/components/ui/Slider/Slider.tsx @@ -1,5 +1,5 @@ import cx from 'classnames'; -import React, { FC, useState, useEffect } from 'react'; +import React, { FC, useState, useEffect, useRef } from 'react'; import ReactSlider from 'react-slider'; import styles from './Slider.module.scss'; @@ -15,7 +15,8 @@ const Slider: FC = ({ hideThumb, ...rest }) => { - const [localValue, setLocalValue] = useState(value); + const reactSliderRef = useRef(null); + const [localValue, setLocalValue] = useState(0); useEffect(() => { if (value !== undefined && value !== localValue) { @@ -40,9 +41,19 @@ const Slider: FC = ({ } }; + useEffect(() => { + if (isDisabled || hideThumb || !reactSliderRef?.current) { + return; + } + // Calling handleResize() method solves the problem with rendering thumb outside the box. + // @ts-expect-error method isn't typed + reactSliderRef.current.handleResize(); + }, [isDisabled, hideThumb]); + return (
Date: Wed, 20 Mar 2024 13:32:34 +0100 Subject: [PATCH 2/4] oct-1478: local value fix --- client/src/components/ui/Slider/Slider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/ui/Slider/Slider.tsx b/client/src/components/ui/Slider/Slider.tsx index 4e058324b7..ecaf16cffc 100644 --- a/client/src/components/ui/Slider/Slider.tsx +++ b/client/src/components/ui/Slider/Slider.tsx @@ -16,7 +16,7 @@ const Slider: FC = ({ ...rest }) => { const reactSliderRef = useRef(null); - const [localValue, setLocalValue] = useState(0); + const [localValue, setLocalValue] = useState(value); useEffect(() => { if (value !== undefined && value !== localValue) { From 4965c91b43ec67be2c90b577b09e9919bd122abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Zi=C3=B3=C5=82ek?= Date: Wed, 20 Mar 2024 21:07:29 +0100 Subject: [PATCH 3/4] OCT-1457 Fix interaction issues with Lock/Unlock flow (#84) --- client/cypress/e2e/earn.cy.ts | 27 ++++++++++++------- .../EarnGlmLockTabs/EarnGlmLockTabs.tsx | 3 ++- .../EarnGlmLockTabsInputs.tsx | 21 +++++++++------ .../EarnGlmLockTabsInputs/types.ts | 2 +- .../src/components/ui/InputText/InputText.tsx | 10 ++++++- client/src/components/ui/InputText/types.ts | 1 + 6 files changed, 43 insertions(+), 21 deletions(-) diff --git a/client/cypress/e2e/earn.cy.ts b/client/cypress/e2e/earn.cy.ts index 89993ec425..241f8836de 100644 --- a/client/cypress/e2e/earn.cy.ts +++ b/client/cypress/e2e/earn.cy.ts @@ -88,17 +88,27 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes cy.get('[data-test=ModalGlmLock__overflow]').should('exist'); }); + it('Wallet connected: "ModalGlmLock" - changing tabs keep focus on first input', () => { + connectWallet(); + cy.get('[data-test=BoxGlmLock__Button]').click(); + cy.get('[data-test=ModalGlmLock]').should('be.visible'); + cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').should('have.focus'); + cy.get('[data-test=EarnGlmLockTabs__tab--1]').click(); + cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').should('have.focus'); + cy.get('[data-test=EarnGlmLockTabs__tab--0]').click(); + cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').should('have.focus'); + }); + it('Wallet connected: Lock 1 GLM', () => { connectWallet(); - cy.get('[data-test=BoxGlmLock__Button]').click(); - cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').blur(); - cy.get('[data-test=BudgetBox__currentlyLocked__value]') + cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]') .invoke('text') .then(text => { const amountToLock = 1; const lockedGlms = parseInt(text, 10); + cy.get('[data-test=BoxGlmLock__Button]').click(); cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').clear().type(`${amountToLock}`); cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Lock'); cy.get('[data-test=GlmLockTabs__Button]').click(); @@ -142,18 +152,15 @@ Object.values(viewports).forEach(({ device, viewportWidth, viewportHeight, isDes it('Wallet connected: Unlock 1 GLM', () => { connectWallet(); - cy.get('[data-test=BoxGlmLock__Button]').click(); - cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').blur(); - cy.get('[data-test=BudgetBox__currentlyLocked__value]') + cy.get('[data-test=BoxGlmLock__Section--current__DoubleValue__primary]') .invoke('text') .then(text => { const amountToUnlock = 1; const lockedGlms = parseInt(text, 10); - cy.get('[data-test=BoxRounded__tab--1]').click(); - cy.get('[data-test=InputsCryptoFiat__InputText--crypto]') - .clear() - .type(`${amountToUnlock}`); + cy.get('[data-test=BoxGlmLock__Button]').click(); + cy.get('[data-test=EarnGlmLockTabs__tab--1]').click(); + cy.get('[data-test=InputsCryptoFiat__InputText--crypto]').clear().type(`${amountToUnlock}`); cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Unlock'); cy.get('[data-test=GlmLockTabs__Button]').click(); cy.get('[data-test=GlmLockTabs__Button]').should('have.text', 'Waiting for confirmation'); diff --git a/client/src/components/Earn/EarnGlmLock/EarnGlmLockTabs/EarnGlmLockTabs.tsx b/client/src/components/Earn/EarnGlmLock/EarnGlmLockTabs/EarnGlmLockTabs.tsx index 0527fea723..4b3abd97b3 100644 --- a/client/src/components/Earn/EarnGlmLock/EarnGlmLockTabs/EarnGlmLockTabs.tsx +++ b/client/src/components/Earn/EarnGlmLock/EarnGlmLockTabs/EarnGlmLockTabs.tsx @@ -88,6 +88,7 @@ const EarnGlmLockTabs: FC = ({ return ( = ({ error={formik.values.valueToDeposeOrWithdraw && formik.errors.valueToDeposeOrWithdraw} inputCryptoProps={{ name: 'valueToDeposeOrWithdraw', - onChange: onSetValue, onClear: formik.resetForm, suffix: 'GLM', value: formik.values.valueToDeposeOrWithdraw, @@ -155,6 +155,7 @@ const EarnGlmLockTabs: FC = ({ )}
} + onChange={onSetValue} onInputsFocusChange={onInputsFocusChange} />