m.section = section_id;
m.readonly = parent.readonly;
- s.tabs = this.tabs;
- s.tab_names = this.tab_names;
+ /* Clone tabs as both array and object. Otherwise calling renderMoreOptionsModal (reopening
+ the same Modal multiple times) results in errors when s.tab is called in the modal. This
+ allows Modal dialogues that declare new tabs to be opened multiple times without re-creating
+ tabs that 'already exist'. */
+ if (this.tabs) {
+ s.tabs = Array.from(this.tabs);
+ for (const key in this.tabs) {
+ if (Object.prototype.hasOwnProperty.call(this.tabs, key) && isNaN(Number(key))) {
+ s.tabs[key] = this.tabs[key];
+ }
+ }
+ } else {
+ s.tabs = undefined;
+ }
+
+ if (this.tab_names) {
+ s.tab_names = Array.isArray(this.tab_names) ? this.tab_names.slice() : Object.assign({}, this.tab_names);
+ } else {
+ s.tab_names = undefined;
+ }
this.cloneOptions(this, s);