Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Comment Does not work #5322

Open
docu-bill opened this issue Jan 29, 2025 · 2 comments
Open

Add Comment Does not work #5322

docu-bill opened this issue Jan 29, 2025 · 2 comments
Assignees
Labels
Area: Word Issue related to Word add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback

Comments

@docu-bill
Copy link

When I add a comment using the insertComment function of the Word.Range object the comment does not appear in the document.

Your Environment

  • Platform Word Online
  • Host: Word
  • Office version number: Latest
  • Operating System: Windows and Mac
  • Browser (if using Office on the web): Edge and Chrome

Expected behavior

After the comment is inserted it should be visible in the coments tab

Current behavior

The comment is not visible to the user who added the comment.
It is visible to other collaborators
Only appears in the comments list after the Word document is reloaded

Steps to reproduce

Add a comment like so:

  await Word.run(async (context) => {
    const selection = context.document.getSelection()
    selection.insertComment(textfieldValue);
    await context.sync()
  })

After adding comment click on the comment symbol, which will disappear and open the comments tab that has no comments in it.
Reload word document and the comment will be there.

YAML file is included below

Context

IF the user cannot see all the comments, then they will not be able to delete them before creating a pdf file... Comments in the document make the pdf file worthless

YAML content:

name: Insert Comment
description: Make a selection in the document and click run
host: WORD
api_set: {}
script:
content: |
$("#run").on("click", () => tryCatch(run));

async function run() {
  await Word.run(async (context) => {
    const selection = context.document.getSelection();
    selection.insertComment("textfieldValue");
    await context.sync();
  });
}

// Default helper for invoking an action and handling errors.
async function tryCatch(callback) {
  try {
    await callback();
  } catch (error) {
    // Note: In a production add-in, you'd want to notify the user through your add-in's UI.
    console.error(error);
  }
}

language: typescript
template:
content: |-

Run

language: html
style:
content: |-
section.samples {
margin-top: 20px;
}

section.samples .ms-Button, section.setup .ms-Button {
    display: block;
    margin-bottom: 5px;
    margin-left: 20px;
    min-width: 80px;
}

language: css
libraries: |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
@types/office-js

[email protected]/dist/css/fabric.min.css
[email protected]/dist/css/fabric.components.min.css

[email protected]/client/core.min.js
@types/core-js

[email protected]
@types/[email protected]

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Area: Word Issue related to Word add-ins label Jan 29, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs: attention 👋 Waiting on Microsoft to provide feedback label Jan 29, 2025
Copy link
Contributor

Thank you for letting us know about this issue. We will take a look shortly. Thanks.

@vincentgggg12
Copy link

I have the same problem: Word JavaScript API - Comments Not Displaying Immediately

Issue Summary:
When adding comments to a Microsoft Word document using the Word JavaScript API, the comments do not immediately appear in the document. A manual browser reload is required for them to become visible.

Environment:

Platform: Office on the Web (Word Online)

Host: Word

Browser: Edge (latest versions tested)

Steps to Reproduce:

Open a Word document in Word Online.

Use the Word JavaScript API to add a comment programmatically.

Observe that the comment is not immediately visible.

Reload the browser.

Observe that the comment now appears in the document.

Expected Behavior:

Comments added via the Word JavaScript API should appear in the document immediately, without requiring a browser reload.

Actual Behavior:

Comments are not displayed until the document is reloaded.

Issue occurs consistently across different browsers.

No error messages are thrown by the API.

Manually adding comments via the Word UI works as expected.

Other API functions like inserting text or tables work immediately without requiring a reload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Word Issue related to Word add-ins Needs: attention 👋 Waiting on Microsoft to provide feedback
Projects
None yet
Development

No branches or pull requests

3 participants