mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	fix: Update duplicate ids for dashboard app frame (#8077)
This commit is contained in:
		@@ -12,7 +12,7 @@
 | 
				
			|||||||
      />
 | 
					      />
 | 
				
			||||||
      <iframe
 | 
					      <iframe
 | 
				
			||||||
        v-if="configItem.type === 'frame' && configItem.url"
 | 
					        v-if="configItem.type === 'frame' && configItem.url"
 | 
				
			||||||
        :id="`dashboard-app--frame-${index}`"
 | 
					        :id="getFrameId(index)"
 | 
				
			||||||
        :src="configItem.url"
 | 
					        :src="configItem.url"
 | 
				
			||||||
        @load="() => onIframeLoad(index)"
 | 
					        @load="() => onIframeLoad(index)"
 | 
				
			||||||
      />
 | 
					      />
 | 
				
			||||||
@@ -39,6 +39,10 @@ export default {
 | 
				
			|||||||
      type: Boolean,
 | 
					      type: Boolean,
 | 
				
			||||||
      default: false,
 | 
					      default: false,
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    position: {
 | 
				
			||||||
 | 
					      type: Number,
 | 
				
			||||||
 | 
					      required: true,
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  data() {
 | 
					  data() {
 | 
				
			||||||
    return {
 | 
					    return {
 | 
				
			||||||
@@ -82,10 +86,14 @@ export default {
 | 
				
			|||||||
    };
 | 
					    };
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  methods: {
 | 
					  methods: {
 | 
				
			||||||
 | 
					    getFrameId(index) {
 | 
				
			||||||
 | 
					      return `dashboard-app--frame-${this.position}-${index}`;
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    onIframeLoad(index) {
 | 
					    onIframeLoad(index) {
 | 
				
			||||||
      const frameElement = document.getElementById(
 | 
					      // A possible alternative is to use ref instead of document.getElementById
 | 
				
			||||||
        `dashboard-app--frame-${index}`
 | 
					      // However, when ref is used together with v-for, the ref you get will be
 | 
				
			||||||
      );
 | 
					      // an array containing the child components mirroring the data source.
 | 
				
			||||||
 | 
					      const frameElement = document.getElementById(this.getFrameId(index));
 | 
				
			||||||
      const eventData = { event: 'appContext', data: this.dashboardAppContext };
 | 
					      const eventData = { event: 'appContext', data: this.dashboardAppContext };
 | 
				
			||||||
      frameElement.contentWindow.postMessage(JSON.stringify(eventData), '*');
 | 
					      frameElement.contentWindow.postMessage(JSON.stringify(eventData), '*');
 | 
				
			||||||
      this.iframeLoading = false;
 | 
					      this.iframeLoading = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,6 +52,7 @@
 | 
				
			|||||||
      :key="currentChat.id + '-' + dashboardApp.id"
 | 
					      :key="currentChat.id + '-' + dashboardApp.id"
 | 
				
			||||||
      :is-visible="activeIndex - 1 === index"
 | 
					      :is-visible="activeIndex - 1 === index"
 | 
				
			||||||
      :config="dashboardApps[index].content"
 | 
					      :config="dashboardApps[index].content"
 | 
				
			||||||
 | 
					      :position="index"
 | 
				
			||||||
      :current-chat="currentChat"
 | 
					      :current-chat="currentChat"
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
  </div>
 | 
					  </div>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user