Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #904 from nextcloud/enh/noid/allow-async-renderCus…
Browse files Browse the repository at this point in the history
…tomPickerElement
  • Loading branch information
juliusknorr authored Feb 10, 2023
2 parents eec561d + 3349205 commit bb5fa6e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/referencePicker/CustomPickerElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,19 @@ export default {
this.$refs.domElement.innerHTML = ''
}
this.renderResult = renderCustomPickerElement(this.$refs.domElement, { providerId: this.provider.id, accessible: false })
if (this.renderResult.object?._isVue && this.renderResult.object?.$on) {
this.renderResult.object.$on('submit', this.onSubmit)
this.renderResult.object.$on('cancel', this.onCancel)
}
this.renderResult.element.addEventListener('submit', (e) => {
this.onSubmit(e.detail)
const renderFunctionResult = renderCustomPickerElement(this.$refs.domElement, { providerId: this.provider.id, accessible: false })
// this works whether renderCustomPickerElement returns a promise or a value
Promise.resolve(renderFunctionResult).then(result => {
this.renderResult = result
if (this.renderResult.object?._isVue && this.renderResult.object?.$on) {
this.renderResult.object.$on('submit', this.onSubmit)
this.renderResult.object.$on('cancel', this.onCancel)
}
this.renderResult.element.addEventListener('submit', (e) => {
this.onSubmit(e.detail)
})
this.renderResult.element.addEventListener('cancel', this.onCancel)
})
this.renderResult.element.addEventListener('cancel', this.onCancel)
},
onSubmit(value) {
this.$emit('submit', value)
Expand Down

0 comments on commit bb5fa6e

Please sign in to comment.