0

I am working on an Office Word add-in using Angular 5. I have a weird issue where clicking on any route link scales the viewport zoom level down by a small percentage each click until everything is very small. I have set the location strategy to hash.

  • I have removed all css and still experience the issue.
  • Tried with and without viewport meta tag and @-ms-viewport css property with various settings.
  • Tried setting the X-UA-Compatible meta tag to various versions of IE.

Wondering if anyone has experienced similar.

Update:

I have tried with the following add-in and experience the same issue by clicking on the route links. https://github.com/OfficeDev/Word-Add-in-Angular2-StyleChecker

enter image description here

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Office Add In</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <base href="/">
  <script src="https://appsforoffice.microsoft.com/lib/1/hosted/Office.js" type="text/javascript"></script>
</head>
<body>
  <app-root>Loading...</app-root>
</body>
</html>

Main Template

<div class="root-navigation">
    <div class="navigation-links">
        <a routerLink="/tab1" [routerLinkActive]="['active']">
            Tab 1
        </a>
        <a routerLink="/tab2" [routerLinkActive]="['active']">
            Tab 2
        </a>
    </div>
</div>
<div class="root-viewport">
    <router-outlet></router-outlet>
</div>

1 Answer 1

1

NOTE: This answer won't contain a solution to the problem, because it would be too long to post as a comment.


TL;DR: It looks like there's a bug in Word 2016 for Windows that affects window.devicePixelRatio for OfficeJS add-ins that use Angular's Router. This bug does not occur on Word Online using either IE11 or Chrome.

Version Numbers:

Windows 10:
Version 1709 (OS Build 16299.125)

Word 2016:
Version 1801 (Build 8911.2016 Click-to-Run) (Office Insider)
WordApi 1.3

Internet Explorer 11:
Version 11.125.16299.0
Update Versions: 11.0.49 (KB4052978)


Longer Version: I also noticed this and thought it was Angular's router. By logging the value of window.devicePixelRatio, I could see that its value was steadily decreasing with each router navigation. Bizarre, given that it's supposed to be read-only!

So I spent some time creating a simple repro as preparation for opening a ticket on their GitHub repo.

However, I could not reproduce the problem with my extremely simple example on Chrome and IE11.

So, I added OfficeJS to the example in a separate branch and did some testing. Here are my findings:

Simple Angular App

In this scenario, there is no OfficeJS. I access the app using browsers directly.

  • The initial value of window.devicePixelRatio on Chrome and IE11 is 1.
  • Navigating between tabs does not change this value.

OfficeJS Add-in

Here, the add-in is loaded by the host (Word Online or Word 2016 for Windows), which runs in its own browser process. Side-loading manifest info here.

Word Online

  • The initial value of window.devicePixelRatio on Chrome in Word Online is 1.
  • The initial value of window.devicePixelRatio on IE11 in Word Online is also 1.
  • Navigating between tabs in either browser does not change this value.

Word 2016 for Windows

  • The initial value of window.devicePixelRatio on IE11 in Word 2016 is 1.
  • Navigating between tabs does change this value! Specifically, the value decreases, and with enough navigations, the content of the add-in appears to shrink.

So yeah, you're not crazy. :) Maybe someone from the OfficeJS team could help with this?

Sign up to request clarification or add additional context in comments.

1 Comment

Looks like they are already aware of the issue. github.com/OfficeDev/office-js/issues/40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.