Skip to content

Commit 1e368af

Browse files
feat(onboarding): scroll next page into view if previous page was scrolled (#5905)
1 parent cb4b341 commit 1e368af

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

src/homepageExperience/containers/ArduinoWizard.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import WriteDataDetailsContextProvider from 'src/writeData/components/WriteDataD
2626

2727
// Utils
2828
import {event} from 'src/cloud/utils/reporting'
29-
import {HOMEPAGE_NAVIGATION_STEPS_ARDUINO} from 'src/homepageExperience/utils'
29+
import {
30+
scrollNextPageIntoView,
31+
HOMEPAGE_NAVIGATION_STEPS_ARDUINO,
32+
} from 'src/homepageExperience/utils'
3033
import {normalizeEventName} from 'src/cloud/utils/reporting'
3134
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
3235
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
@@ -85,6 +88,7 @@ export class ArduinoWizard extends PureComponent<{}, State> {
8588
),
8689
}
8790
)
91+
scrollNextPageIntoView()
8892
}
8993
)
9094
}
@@ -105,6 +109,7 @@ export class ArduinoWizard extends PureComponent<{}, State> {
105109
),
106110
}
107111
)
112+
scrollNextPageIntoView()
108113
}
109114
)
110115
}
@@ -120,6 +125,7 @@ export class ArduinoWizard extends PureComponent<{}, State> {
120125
),
121126
}
122127
)
128+
scrollNextPageIntoView()
123129
}
124130

125131
renderStep = () => {

src/homepageExperience/containers/CliWizard.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import WriteDataDetailsContextProvider from 'src/writeData/components/WriteDataD
2525

2626
// Utils
2727
import {event} from 'src/cloud/utils/reporting'
28-
import {HOMEPAGE_NAVIGATION_STEPS_SHORT} from 'src/homepageExperience/utils'
28+
import {
29+
scrollNextPageIntoView,
30+
HOMEPAGE_NAVIGATION_STEPS_SHORT,
31+
} from 'src/homepageExperience/utils'
2932
import {normalizeEventName} from 'src/cloud/utils/reporting'
3033
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
3134
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
@@ -84,6 +87,8 @@ export class CliWizard extends PureComponent<{}, State> {
8487
),
8588
}
8689
)
90+
91+
scrollNextPageIntoView()
8792
}
8893
)
8994
}
@@ -104,6 +109,8 @@ export class CliWizard extends PureComponent<{}, State> {
104109
),
105110
}
106111
)
112+
113+
scrollNextPageIntoView()
107114
}
108115
)
109116
}
@@ -119,6 +126,7 @@ export class CliWizard extends PureComponent<{}, State> {
119126
),
120127
}
121128
)
129+
scrollNextPageIntoView()
122130
}
123131

124132
renderStep = () => {

src/homepageExperience/containers/GoWizard.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import {normalizeEventName} from 'src/cloud/utils/reporting'
2323

2424
import {GoIcon} from 'src/homepageExperience/components/HomepageIcons'
2525

26-
import {HOMEPAGE_NAVIGATION_STEPS} from 'src/homepageExperience/utils'
27-
2826
// Utils
2927
import {event} from 'src/cloud/utils/reporting'
3028
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
3129
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
30+
import {
31+
scrollNextPageIntoView,
32+
HOMEPAGE_NAVIGATION_STEPS,
33+
} from 'src/homepageExperience/utils'
3234

3335
interface State {
3436
currentStep: number
@@ -84,6 +86,7 @@ export class GoWizard extends PureComponent<null, State> {
8486
),
8587
}
8688
)
89+
scrollNextPageIntoView()
8790
}
8891
)
8992
}
@@ -104,6 +107,7 @@ export class GoWizard extends PureComponent<null, State> {
104107
),
105108
}
106109
)
110+
scrollNextPageIntoView()
107111
}
108112
)
109113
}
@@ -119,6 +123,7 @@ export class GoWizard extends PureComponent<null, State> {
119123
),
120124
}
121125
)
126+
scrollNextPageIntoView()
122127
}
123128

124129
renderStep = () => {

src/homepageExperience/containers/NodejsWizard.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import {normalizeEventName} from 'src/cloud/utils/reporting'
2323

2424
import {NodejsIcon} from 'src/homepageExperience/components/HomepageIcons'
2525

26-
import {HOMEPAGE_NAVIGATION_STEPS} from 'src/homepageExperience/utils'
27-
2826
// Utils
2927
import {event} from 'src/cloud/utils/reporting'
3028
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
3129
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
30+
import {
31+
scrollNextPageIntoView,
32+
HOMEPAGE_NAVIGATION_STEPS,
33+
} from 'src/homepageExperience/utils'
3234

3335
interface State {
3436
currentStep: number
@@ -84,6 +86,7 @@ export class NodejsWizard extends PureComponent<null, State> {
8486
),
8587
}
8688
)
89+
scrollNextPageIntoView()
8790
}
8891
)
8992
}
@@ -104,6 +107,7 @@ export class NodejsWizard extends PureComponent<null, State> {
104107
),
105108
}
106109
)
110+
scrollNextPageIntoView()
107111
}
108112
)
109113
}
@@ -119,6 +123,7 @@ export class NodejsWizard extends PureComponent<null, State> {
119123
),
120124
}
121125
)
126+
scrollNextPageIntoView()
122127
}
123128

124129
renderStep = () => {

src/homepageExperience/containers/PythonWizard.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@ import {normalizeEventName} from 'src/cloud/utils/reporting'
2424

2525
import {PythonIcon} from 'src/homepageExperience/components/HomepageIcons'
2626

27-
import {HOMEPAGE_NAVIGATION_STEPS} from 'src/homepageExperience/utils'
28-
2927
// Utils
3028
import {event} from 'src/cloud/utils/reporting'
3129
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
3230
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
31+
import {
32+
scrollNextPageIntoView,
33+
HOMEPAGE_NAVIGATION_STEPS,
34+
} from 'src/homepageExperience/utils'
3335

3436
interface State {
3537
currentStep: number
@@ -85,6 +87,7 @@ export class PythonWizard extends PureComponent<null, State> {
8587
),
8688
}
8789
)
90+
scrollNextPageIntoView()
8891
}
8992
)
9093
}
@@ -105,6 +108,7 @@ export class PythonWizard extends PureComponent<null, State> {
105108
),
106109
}
107110
)
111+
scrollNextPageIntoView()
108112
}
109113
)
110114
}
@@ -120,6 +124,7 @@ export class PythonWizard extends PureComponent<null, State> {
120124
),
121125
}
122126
)
127+
scrollNextPageIntoView()
123128
}
124129

125130
renderStep = () => {

src/homepageExperience/utils.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {IconFont} from '@influxdata/clockface'
22

3+
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
4+
35
export const HOMEPAGE_NAVIGATION_STEPS = [
46
{
57
name: 'Overview',
@@ -100,3 +102,18 @@ export const HOMEPAGE_NAVIGATION_STEPS_ARDUINO = [
100102
glyph: IconFont.StarSmile,
101103
},
102104
]
105+
106+
// Each onboarding page in the wizard has a single h1 at the top of it. Attempt to scroll it into view smoothly
107+
// Set a timeout of 0 so that this function call gets run after react has a had a chance to update state and
108+
// re-render on the main thread.
109+
export const scrollNextPageIntoView = () => {
110+
if (isFlagEnabled('firstMileScrollTop')) {
111+
setTimeout(() => {
112+
document.querySelector('h1').scrollIntoView({
113+
behavior: 'smooth',
114+
block: 'nearest',
115+
inline: 'nearest',
116+
})
117+
}, 0)
118+
}
119+
}

0 commit comments

Comments
 (0)