diff --git a/src/demo/js/options/config.js b/src/demo/js/options/config.js index 3cf6d845..035216f0 100644 --- a/src/demo/js/options/config.js +++ b/src/demo/js/options/config.js @@ -18,9 +18,10 @@ const config = { events: { onRender: element => { console.log(element) - setTimeout(() => { + const onRenderTimeout = setTimeout(() => { // formeo.Components.fields.get(element.id).toggleEdit(true) element.querySelector('.next-group').click() + clearTimeout(onRenderTimeout) }, 333) }, }, diff --git a/src/js/common/dom.js b/src/js/common/dom.js index b52ff83b..07a70cbc 100644 --- a/src/js/common/dom.js +++ b/src/js/common/dom.js @@ -780,10 +780,6 @@ class DOM { document.dispatchEvent(events.columnResized) }) - // fields.forEach(fieldId => Fields.get(fieldId).panelNav.refresh()) - - // setTimeout(() => fields.forEach(fieldId => Fields.get(fieldId).panelNav.refresh()), 250) - dom.updateColumnPreset(row) } diff --git a/src/js/components/fields/edit-panel-item.js b/src/js/components/fields/edit-panel-item.js index 3b03dd26..26785c15 100644 --- a/src/js/components/fields/edit-panel-item.js +++ b/src/js/components/fields/edit-panel-item.js @@ -230,29 +230,27 @@ export default class EditPanelItem { } const hideFields = fields => { fields = Array.isArray(fields) ? fields : [fields] - setTimeout( - () => - fields.forEach(field => { - if (field.dom) { - field = field.dom - } - field.style.display = 'none' - }), - ANIMATION_SPEED_BASE - ) + const hideFieldsTimeout = setTimeout(() => { + fields.forEach(field => { + if (field.dom) { + field = field.dom + } + field.style.display = 'none' + }) + clearTimeout(hideFieldsTimeout) + }, ANIMATION_SPEED_BASE) } const showFields = fields => { fields = Array.isArray(fields) ? fields : [fields] - setTimeout( - () => - fields.forEach(field => { - if (field.dom) { - field = field.dom - } - field.removeAttribute('style') - }), - ANIMATION_SPEED_BASE - ) + const showFieldsTimeout = setTimeout(() => { + fields.forEach(field => { + if (field.dom) { + field = field.dom + } + field.removeAttribute('style') + }) + clearTimeout(showFieldsTimeout) + }, ANIMATION_SPEED_BASE) } const actions = new Map([ [ diff --git a/src/js/components/fields/field.js b/src/js/components/fields/field.js index dab98381..6eedb47b 100644 --- a/src/js/components/fields/field.js +++ b/src/js/components/fields/field.js @@ -158,7 +158,7 @@ export default class Field extends Component { * Updates the conditions panel when linked field data changes */ updateConditionsPanel = () => { - setTimeout(() => { + const updateConditionsTimeout = setTimeout(() => { const newConditionsPanel = this.editPanels.find(({ name }) => name === 'conditions') if (!newConditionsPanel) { return null @@ -166,6 +166,7 @@ export default class Field extends Component { const newProps = newConditionsPanel.createProps() const currentConditionsProps = this.dom.querySelector('.field-edit-conditions') currentConditionsProps.parentElement.replaceChild(newProps, currentConditionsProps) + clearTimeout(updateConditionsTimeout) }, ANIMATION_SPEED_BASE) }