Skip to content

Commit

Permalink
fix: distinguish yandex form surveys path url as param with cloud def…
Browse files Browse the repository at this point in the history
…ault
  • Loading branch information
qradle-yndx committed Oct 26, 2023
1 parent dfa4b0e commit 3b2bebb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/YandexForm/YandexForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {block} from '../../utils';
import {HEADER_HEIGHT} from '../constants';

export const YANDEX_FORM_ORIGIN = 'https://forms.yandex.ru';
export const YANDEX_FORM_SECTION = 'cloud';
const CONTAINER_ID = 'pc-yandex-form-container';

const b = block('yandex-form');
Expand All @@ -28,10 +29,12 @@ const YandexForm = (props: YandexFormProps) => {
pixelEvents,
analyticsEvents,
customFormOrigin,
customFormSection,
} = props;
const formContainerRef = useRef<HTMLDivElement>(null);
const iframeRef = useRef<HTMLIFrameElement>();
const yaFormOrigin = customFormOrigin || YANDEX_FORM_ORIGIN;
const yaFormSection = customFormSection || YANDEX_FORM_SECTION;

const handleMetrika = useMetrika();
const handleAnalytics = useAnalytics(DefaultEventNames.YandexFormSubmit);
Expand Down Expand Up @@ -62,7 +65,7 @@ const YandexForm = (props: YandexFormProps) => {
});
}

const src = `${yaFormOrigin}/surveys/${id}/?${queryParams}`;
const src = `${yaFormOrigin}/${yaFormSection}/${id}/?${queryParams}`;

if (iframeRef.current) {
iframeRef.current.src = src;
Expand Down
2 changes: 1 addition & 1 deletion src/components/YandexForm/__stories__/data.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"default": {
"content": {
"id": "10034371.a94dac9d3bd19f65c9616db0297348ad8d063db0"
"id": "61a4e639d4d24e0dbba36f5c"
}
}
}
1 change: 1 addition & 0 deletions src/models/constructor-items/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ export interface YandexFormProps extends AnalyticsEventsBase {
className?: string;
headerHeight?: number;
customFormOrigin?: string;
customFormSection?: string;
params?: {[key: string]: string};

onSubmit?: () => void;
Expand Down

0 comments on commit 3b2bebb

Please sign in to comment.