From e1e0232a16d6d0c2b1327b932807a4ce9314bd57 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Thu, 10 Sep 2026 15:28:38 +0200 Subject: [PATCH] fix(viewer): show the modal when it carries only an error The modal renders on an error with no file, which is what an open that never got as far as a file leaves behind: `openFolder` on something that is not a folder, a listing that fails, an unknown handler id. Its `show` prop only followed the file though, and NcModal hides its content with `v-show`, so all of those ended as a click that appeared to do nothing. The stub the viewer tests mount honoured `show` no more than the viewer did, which is why every one of those cases looked reported. It mirrors the `v-show` now, and an error inside a hidden modal no longer counts. Assisted-by: ClaudeCode:claude-opus-5 Signed-off-by: skjnldsv --- __tests__/component/Viewer.spec.ts | 8 +++++--- __tests__/component/mountViewer.ts | 6 +++++- lib/views/Viewer.vue | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/__tests__/component/Viewer.spec.ts b/__tests__/component/Viewer.spec.ts index 9211233..70dcbbb 100644 --- a/__tests__/component/Viewer.spec.ts +++ b/__tests__/component/Viewer.spec.ts @@ -87,15 +87,17 @@ describe('Viewer.open()', () => { }) it('shows an error when the explicit handlerId is not registered', async () => { - const { vm, wrapper, errorText, modalProps } = mountViewer([imageHandler()]) + const { vm, wrapper, errorText, modalProps, renderedTags } = mountViewer([imageHandler()]) const f1 = makeFile({ mime: 'image/jpeg' }) await vm.open([f1], f1, undefined, 'does-not-exist') await wrapper.vm.$nextTick() expect(errorText()).toBe('There was no plugin available to open this file.') - // No file got opened. - expect(modalProps().show).toBe(false) + // No file got opened, but the modal is shown regardless: it is what + // carries the error, and it hides its content while `show` is false. + expect(renderedTags()).toEqual([]) + expect(modalProps().show).toBe(true) }) it.each([ diff --git a/__tests__/component/mountViewer.ts b/__tests__/component/mountViewer.ts index 5b542d4..92ef782 100644 --- a/__tests__/component/mountViewer.ts +++ b/__tests__/component/mountViewer.ts @@ -40,6 +40,7 @@ export const NcModalStub = defineComponent({ emits: ['next', 'previous', 'close'], template: `
findModal().exists(), renderedTags, errorText: () => { + // The real modal hides its content with `v-show`, which the stub + // mirrors: an error inside a modal that is not shown is an error + // nobody can read, so it does not count as being reported. const ec = wrapper.find('.nc-empty-content-stub') - return ec.exists() ? ec.attributes('data-name') : undefined + return ec.exists() && ec.isVisible() ? ec.attributes('data-name') : undefined }, } } diff --git a/lib/views/Viewer.vue b/lib/views/Viewer.vue index 07b8f79..de75081 100644 --- a/lib/views/Viewer.vue +++ b/lib/views/Viewer.vue @@ -20,7 +20,7 @@ :inlineActions="canEdit ? 1 : 0" :lightBackdrop="lightBackdrop" :name="modalName" - :show="!!currentFile" + :show="!!currentFile || !!errorString" :slideshowPaused="editing" :spreadNavigation="true" :style="{ width: isSidebarShown ? `${sidebarPosition}px` : null }"