Skip to content

Commit 77d2446

Browse files
authored
Merge pull request #941 from AppQuality/fix-insight-form
Fix-insight-form
2 parents 8dbe53c + a5f4cfa commit 77d2446

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/pages/Insights/InsightsDrawer/InsightForm.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { useParams } from 'react-router-dom';
2323
import { getColorWithAlpha } from 'src/common/utils';
2424
import { useEffect, useState } from 'react';
2525
import { styled } from 'styled-components';
26+
import { Divider } from 'src/common/components/divider';
2627
import { InsightFormValues } from '../FormProvider';
2728
import { RadioTag } from '../../Video/components/ObservationForm';
2829
import { ObservationCard } from '../Collection/ObservationCard';
@@ -60,6 +61,7 @@ const InsightForm = () => {
6061
return (
6162
<FormContainer>
6263
<XL isBold>{t('__INSIGHTS_PAGE_INSIGHT_FORM_TITLE')}</XL>
64+
<Divider />
6365
<div>
6466
<Label>{t('__INSIGHTS_PAGE_INSIGHT_FORM_FIELD_TITLE_LABEL')}</Label>
6567
<Field name="title">
@@ -189,6 +191,7 @@ const InsightForm = () => {
189191
))}
190192
</div>
191193
</div>
194+
<Divider />
192195
<div>
193196
<Label>
194197
{t('__INSIGHTS_PAGE_INSIGHT_FORM_FIELD_OBSERVATIONS_LABEL')}

src/pages/Insights/InsightsDrawer/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ReactComponent as InsightIcon } from '@zendeskgarden/svg-icons/src/16/l
1515
import { ReactComponent as EmptyInsights } from 'src/assets/empty-insights.svg';
1616
import { useParams } from 'react-router-dom';
1717
import { Divider } from 'src/common/components/divider';
18-
import { useMemo } from 'react';
18+
import { useEffect, useMemo, useRef } from 'react';
1919
import { Insight } from './InsightAccordion';
2020
import { InsightFormValues } from '../FormProvider';
2121
import { InsightForm } from './InsightForm';
@@ -51,6 +51,8 @@ const InsightsDrawer = () => {
5151
const { campaignId } = useParams();
5252
const { values } = useFormikContext<InsightFormValues>();
5353
const { t } = useTranslation();
54+
const ref = useRef<HTMLDivElement>(null);
55+
5456
const {
5557
data: insights,
5658
isFetching,
@@ -65,10 +67,17 @@ const InsightsDrawer = () => {
6567
[insights]
6668
);
6769

70+
// Reset drawer scroll on editing mode change
71+
useEffect(() => {
72+
if (ref.current) {
73+
ref.current.scrollTop = 0;
74+
}
75+
}, [values.id]);
76+
6877
if (isLoading || isError) return <Skeleton />;
6978

7079
return (
71-
<DetailContainer>
80+
<DetailContainer ref={ref}>
7281
<div
7382
style={{ paddingTop: appTheme.space.xs, opacity: isFetching ? 0.5 : 1 }}
7483
>

0 commit comments

Comments
 (0)