Skip to content

Commit

Permalink
adding bugfixes for js
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Aug 4, 2023
1 parent a7589e1 commit dcfbd5c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/Blocks/components/form/assets/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ export class Form {
this.setupInputField(formId, name);

if (this.state.getStateFormConfigPhoneDisablePicker(formId)) {
this.state.getStateElementField(name, formId).querySelector('select').remove();
this.state.getStateElementField(name, formId).querySelector('select')?.remove();
} else {
this.setupSelectField(formId, name);
}
Expand Down Expand Up @@ -1057,6 +1057,8 @@ export class Form {
input.setAttribute('rows', '1');
input.setAttribute('cols', '');

this.state.setStateElementCustom(name, autosize?.default, formId);

autosize.default(input);
});

Expand Down Expand Up @@ -1214,6 +1216,10 @@ export class Form {

// Clear form state only.
[...formIds].forEach((formId) => {
[...this.state.getStateElementByType('textarea', formId)].forEach((textarea) => {
this.state.getStateElementCustom(textarea.name, formId).destroy(this.state.getStateElementInput(textarea.name, formId));
});

removeStateForm(formId);
});
}
Expand Down
8 changes: 7 additions & 1 deletion src/Blocks/components/form/assets/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,14 @@ export class State {
getFormFieldElementByChild = (element) => {
return element.closest(this.getStateSelectorsField());
};
getFormId = (element) => {
return element.getAttribute(getStateAttribute('formId'));
};
getFormIdByElement = (element) => {
return element.closest(this.getStateSelectorsForm()).getAttribute(getStateAttribute('formId'));
return this.getFormElementByChild(element).getAttribute(getStateAttribute('formId'));
};
getFieldNameByElement = (element) => {
return this.getFormFieldElementByChild(element).getAttribute(getStateAttribute('fieldName'));
};
getRestUrl = (value) => {
return getRestUrl(value);
Expand Down
9 changes: 6 additions & 3 deletions src/Blocks/components/form/assets/state/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ export function setStateFormInitial(formId) {
if (!value) {
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], '', formId);
} else {
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], `${getState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COUNTRY], formId).number}${value}`, formId);
const countryValue = getState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COUNTRY], formId)?.number ?? '';
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], `${countryValue}${value}`, formId);
}
break;
case 'date':
Expand Down Expand Up @@ -600,7 +601,8 @@ export function setStateValues(item, formId) {
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], '', formId);

if (getState([StateEnum.ELEMENTS, name, StateEnum.VALUE], formId)) {
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], `${getState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COUNTRY], formId).number}${getState([StateEnum.ELEMENTS, name, StateEnum.VALUE], formId)}`, formId);
const countryValue = getState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COUNTRY], formId)?.number ?? '';
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], `${countryValue}${getState([StateEnum.ELEMENTS, name, StateEnum.VALUE], formId)}`, formId);
}
}
break;
Expand All @@ -609,7 +611,8 @@ export function setStateValues(item, formId) {
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], '', formId);

if (value) {
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], `${getState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COUNTRY], formId).number}${value}`, formId);
const countryValue = getState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COUNTRY], formId)?.number ?? '';
setState([StateEnum.ELEMENTS, name, StateEnum.VALUE_COMBINED], `${countryValue}${value}`, formId);
}
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/Hooks/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ class Filters
'hideGlobalMsgTimeout' => 'hide_global_msg_timeout',
'successRedirectUrl' => 'success_redirect_url',
'successRedirectVariation' => 'success_redirect_variation',
'successRedirectVariationOptions' => 'success_redirect_variation_options',
'trackingEventName' => 'tracking_event_name',
'trackingAdditionalData' => 'tracking_additional_data',
'dataTypeSelector' => 'data_type_selector',
Expand Down Expand Up @@ -391,6 +392,7 @@ class Filters
],
SettingsActiveCampaign::SETTINGS_TYPE_KEY => [
'data' => 'data',
'prePostParams' => 'pre_post_params',
'successRedirectUrl' => 'success_redirect_url',
],
SettingsAirtable::SETTINGS_TYPE_KEY => [
Expand Down

0 comments on commit dcfbd5c

Please sign in to comment.