Skip to content

Commit

Permalink
fix: loading pdf files with Safari
Browse files Browse the repository at this point in the history
Due to a Safari bug, we must not use `application/pdf` as object type when loading PDF files.
  • Loading branch information
JammingBen committed Aug 10, 2023
1 parent dd2c63c commit 6845e4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/bugfix-pdf-loading-safari
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: PDF loading Safari

Loading PDF files with Safari has been fixed.

https://github.com/owncloud/web/issues/9483
https://github.com/owncloud/web/pull/9565
14 changes: 11 additions & 3 deletions packages/web-app-pdf-viewer/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<loading-screen v-if="loading" />
<error-screen v-else-if="loadingError" />
<div v-else class="oc-height-1-1">
<object class="pdf-viewer oc-height-1-1 oc-width-1-1" :data="url" type="application/pdf" />
<object class="pdf-viewer oc-height-1-1 oc-width-1-1" :data="url" :type="objectType" />
</div>
</main>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { computed, defineComponent } from 'vue'
import { useAppDefaults } from 'web-pkg/src/composables'
import AppTopBar from 'web-pkg/src/components/AppTopBar.vue'
import ErrorScreen from './components/ErrorScreen.vue'
Expand All @@ -23,10 +23,18 @@ export default defineComponent({
LoadingScreen
},
setup() {
const isSafari = () =>
navigator.userAgent?.includes('Safari') && !navigator.userAgent?.includes('Chrome')
const objectType = computed(() => {
// object type must not be 'application/pdf' for Safari due to a bug
return isSafari() ? undefined : 'application/pdf'
})
return {
...useAppDefaults({
applicationId: 'pdf-viewer'
})
}),
objectType
}
},
data: () => ({
Expand Down

0 comments on commit 6845e4d

Please sign in to comment.