Skip to content

Commit 891b717

Browse files
subirjollySubir Jolly
andauthored
feat: add onFocus for subscription sections (#4991)
* feat: add onFocus for subscription sections * chore: remove unused import Co-authored-by: Subir Jolly <sjolly@influxdata.com>
1 parent 480ac32 commit 891b717

File tree

8 files changed

+66
-10
lines changed

8 files changed

+66
-10
lines changed

src/writeData/subscriptions/components/BrokerDetails.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ interface Props {
4444
loading: any
4545
saveForm: (any) => void
4646
setStatus: (any) => void
47+
onFocus?: () => void
4748
}
4849

4950
const BrokerDetails: FC<Props> = ({
@@ -54,13 +55,20 @@ const BrokerDetails: FC<Props> = ({
5455
loading,
5556
saveForm,
5657
setStatus,
58+
onFocus,
5759
}) => {
5860
const history = useHistory()
5961
const org = useSelector(getOrg)
6062
const {navbarMode} = useContext(AppSettingContext)
6163
const navbarOpen = navbarMode === 'expanded'
64+
6265
return (
63-
<div className="update-broker-form" id="broker">
66+
<div
67+
className="update-broker-form"
68+
id="broker"
69+
onFocus={onFocus}
70+
tabIndex={-1}
71+
>
6472
<SpinnerContainer spinnerComponent={<TechnoSpinner />} loading={loading}>
6573
<Form onSubmit={() => {}} testID="update-broker-form-overlay">
6674
<div

src/writeData/subscriptions/components/BrokerForm.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,15 @@ interface Props {
5151
formContent: Subscription
5252
updateForm: (any) => void
5353
saveForm: (any) => void
54+
onFocus?: (any) => void
5455
}
5556

56-
const BrokerForm: FC<Props> = ({formContent, updateForm, saveForm}) => {
57+
const BrokerForm: FC<Props> = ({
58+
formContent,
59+
updateForm,
60+
saveForm,
61+
onFocus,
62+
}) => {
5763
const history = useHistory()
5864
const org = useSelector(getOrg)
5965
// enabled for PAYG accounts and specific free accounts where a flag is enabled
@@ -66,7 +72,12 @@ const BrokerForm: FC<Props> = ({formContent, updateForm, saveForm}) => {
6672
const navbarOpen = navbarMode === 'expanded'
6773
return (
6874
formContent && (
69-
<div className="create-broker-form" id="broker">
75+
<div
76+
className="create-broker-form"
77+
id="broker"
78+
onFocus={onFocus}
79+
tabIndex={-1}
80+
>
7081
<Form onSubmit={() => {}} testID="create-broker-form-overlay">
7182
<div
7283
className="create-broker-form__fixed"

src/writeData/subscriptions/components/CreateSubscriptionPage.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ const CreateSubscriptionPage: FC = () => {
9999
{feature: 'subscriptions'}
100100
)
101101
document
102-
.getElementById(stepsWithIsCompletedStatus[step - 1].type)
102+
.getElementById(SUBSCRIPTION_NAVIGATION_STEPS[step - 1].type)
103103
?.scrollIntoView({behavior: 'smooth', block: 'center'})
104-
setFormActive(stepsWithIsCompletedStatus[step - 1].type as Steps)
104+
setFormActive(SUBSCRIPTION_NAVIGATION_STEPS[step - 1].type as Steps)
105105
setCompletedSteps({
106106
[Steps.BrokerForm]: stepsStatus.brokerStepCompleted === 'true',
107107
[Steps.SubscriptionForm]:
@@ -136,14 +136,20 @@ const CreateSubscriptionPage: FC = () => {
136136
formContent={formContent}
137137
updateForm={updateForm}
138138
saveForm={saveForm}
139+
onFocus={() => setFormActive(Steps.BrokerForm)}
139140
/>
140141
<SubscriptionForm
141142
formContent={formContent}
142143
updateForm={updateForm}
143144
buckets={buckets}
144145
bucket={bucket}
146+
onFocus={() => setFormActive(Steps.SubscriptionForm)}
147+
/>
148+
<ParsingForm
149+
formContent={formContent}
150+
updateForm={updateForm}
151+
onFocus={() => setFormActive(Steps.ParsingForm)}
145152
/>
146-
<ParsingForm formContent={formContent} updateForm={updateForm} />
147153
</Page.Contents>
148154
</SpinnerContainer>
149155
</Page>

src/writeData/subscriptions/components/DetailsSubscriptionPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,21 @@ const DetailsSubscriptionPage: FC = () => {
147147
loading={loading}
148148
setStatus={setStatus}
149149
saveForm={saveForm}
150+
onFocus={() => setFormActive(Steps.BrokerForm)}
150151
/>
151152
<SubscriptionDetails
152153
currentSubscription={currentSubscription}
153154
updateForm={updateForm}
154155
buckets={buckets}
155156
bucket={bucket}
156157
edit={isEditEnabled}
158+
onFocus={() => setFormActive(Steps.SubscriptionForm)}
157159
/>
158160
<ParsingDetails
159161
currentSubscription={currentSubscription}
160162
updateForm={updateForm}
161163
edit={isEditEnabled}
164+
onFocus={() => setFormActive(Steps.ParsingForm)}
162165
/>
163166
</Page.Contents>
164167
</SpinnerContainer>

src/writeData/subscriptions/components/ParsingDetails.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,24 @@ interface Props {
1919
currentSubscription: Subscription
2020
updateForm: (any) => void
2121
edit: boolean
22+
onFocus?: () => void
2223
}
2324

24-
const ParsingDetails: FC<Props> = ({currentSubscription, updateForm, edit}) => (
25+
const ParsingDetails: FC<Props> = ({
26+
currentSubscription,
27+
updateForm,
28+
edit,
29+
onFocus,
30+
}) => (
2531
<div
2632
className={
2733
currentSubscription.dataFormat === 'lineprotocol'
2834
? 'update-parsing-form--line-protocol'
2935
: 'update-parsing-form'
3036
}
3137
id="parsing"
38+
onFocus={onFocus}
39+
tabIndex={-1}
3240
>
3341
<Form onSubmit={() => {}} testID="update-parsing-form-overlay">
3442
<Overlay.Header title="Define Data Parsing Rules"></Overlay.Header>

src/writeData/subscriptions/components/ParsingForm.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ import 'src/writeData/subscriptions/components/ParsingForm.scss'
2424
interface Props {
2525
formContent: Subscription
2626
updateForm: (any) => void
27+
onFocus?: (any) => void
2728
}
2829

29-
const ParsingForm: FC<Props> = ({formContent, updateForm}) =>
30+
const ParsingForm: FC<Props> = ({formContent, updateForm, onFocus}) =>
3031
formContent && (
3132
<div
3233
className={
@@ -35,6 +36,8 @@ const ParsingForm: FC<Props> = ({formContent, updateForm}) =>
3536
: 'create-parsing-form'
3637
}
3738
id="parsing"
39+
onFocus={onFocus}
40+
tabIndex={-1}
3841
>
3942
<Form onSubmit={() => {}} testID="create-parsing-form-overlay">
4043
<Overlay.Header title="Define Data Parsing Rules"></Overlay.Header>

src/writeData/subscriptions/components/SubscriptionDetails.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ interface Props {
2020
buckets: any
2121
bucket: any
2222
edit: boolean
23+
onFocus?: () => void
2324
}
2425

2526
const SubscriptionDetails: FC<Props> = ({
@@ -28,18 +29,26 @@ const SubscriptionDetails: FC<Props> = ({
2829
buckets,
2930
bucket,
3031
edit,
32+
onFocus,
3133
}) => {
3234
useEffect(() => {
3335
event('visited subscription details page', {}, {feature: 'subscriptions'})
3436
}, [])
37+
3538
useEffect(() => {
3639
if (edit) {
3740
updateForm({...currentSubscription, bucket: bucket.name})
3841
}
3942
}, [bucket])
43+
4044
return (
4145
buckets && (
42-
<div className="update-subscription-form" id="subscription">
46+
<div
47+
className="update-subscription-form"
48+
id="subscription"
49+
onFocus={onFocus}
50+
tabIndex={-1}
51+
>
4352
<Form
4453
onSubmit={() => {}}
4554
testID="update-subscription-form--overlay-form"

src/writeData/subscriptions/components/SubscriptionForm.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,29 @@ interface Props {
2222
updateForm: (any) => void
2323
buckets: any
2424
bucket: any
25+
onFocus?: (any) => void
2526
}
2627

2728
const SubscriptionForm: FC<Props> = ({
2829
formContent,
2930
updateForm,
3031
buckets,
3132
bucket,
33+
onFocus,
3234
}) => {
3335
useEffect(() => {
3436
updateForm({...formContent, bucket: bucket.name})
3537
}, [bucket])
38+
3639
return (
3740
formContent &&
3841
buckets && (
39-
<div className="create-subscription-form" id="subscription">
42+
<div
43+
className="create-subscription-form"
44+
id="subscription"
45+
onFocus={onFocus}
46+
tabIndex={-1}
47+
>
4048
<Form
4149
onSubmit={() => {}}
4250
testID="create-subscription-form--overlay-form"

0 commit comments

Comments
 (0)