Skip to content

Commit fa27fd3

Browse files
nfebenextcloud-command
authored andcommitted
Handle close GlobalSearchModal gracefully
The current close infrastructure modifies a prop which has no real effect aside bugs. In addition, calling the `NcModal.close()` as the primary way to close the search modal instead of using the states defined in `GlobalSearch` view causing re-open bugs (Modal cannot open, needs to click twice, and other weird stuff). Signed-off-by: fenn-cs <fenn25.fn@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 6e3781b commit fa27fd3

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

core/src/views/GlobalSearch.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<Magnify class="global-search__trigger" :size="22" />
2727
</template>
2828
</NcButton>
29-
<GlobalSearchModal :is-visible="showGlobalSearch" :class="'global-search-modal'" />
29+
<GlobalSearchModal :class="'global-search-modal'" :is-visible="showGlobalSearch" @update:isVisible="handleModalVisibilityChange" />
3030
</div>
3131
</template>
3232

@@ -54,6 +54,9 @@ export default {
5454
toggleGlobalSearch() {
5555
this.showGlobalSearch = !this.showGlobalSearch
5656
},
57+
handleModalVisibilityChange(newVisibilityVal) {
58+
this.showGlobalSearch = newVisibilityVal
59+
},
5760
},
5861
}
5962
</script>

core/src/views/GlobalSearchModal.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<NcModal id="global-search"
33
ref="globalSearchModal"
44
:name="t('core', 'Global search')"
5-
:show.sync="isVisible"
5+
:show.sync="internalIsVisible"
66
:clear-view-delay="0"
77
:title="t('Global search')"
88
@close="closeModal">
@@ -201,6 +201,7 @@ export default {
201201
contacts: [],
202202
debouncedFind: debounce(this.find, 300),
203203
showDateRangeModal: false,
204+
internalIsVisible: false,
204205
}
205206
},
206207
@@ -225,12 +226,17 @@ export default {
225226
},
226227
watch: {
227228
isVisible(value) {
229+
this.internalIsVisible = value
230+
},
231+
internalIsVisible(value) {
232+
this.$emit('update:isVisible', value)
228233
this.$nextTick(() => {
229234
if (value) {
230235
this.focusInput()
231236
}
232237
})
233238
},
239+
234240
},
235241
mounted() {
236242
getProviders().then((providers) => {
@@ -517,7 +523,7 @@ export default {
517523
this.$refs.searchInput.$el.children[0].children[0].focus()
518524
},
519525
closeModal() {
520-
this.$refs.globalSearchModal.close()
526+
this.internalIsVisible = false
521527
this.searchQuery = ''
522528
},
523529
supportFiltering() {

dist/core-global-search.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-global-search.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)