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

Fix duplicate copy warning alert #230

Merged

Conversation

adamdougal
Copy link
Collaborator

Purpose

  • It was being added to the whole page everytime an answer was returned
  • This meant that if any content on the page was copied the alert was being shown multiple times based on how many answers there had been
  • This change will mean the alert will now only be shown when an answer is copied and only once

Required by #215

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid

  • ...

Other Information

@@ -14,11 +14,13 @@ import supersub from 'remark-supersub'
interface Props {
answer: AskResponse;
onCitationClicked: (citedDocument: Citation) => void;
index: Number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
index: Number;
index: number;

@@ -57,15 +59,16 @@ export const Answer = ({
const handleCopy = () => {
alert("Please consider where you paste this content.");
};
document.addEventListener("copy", handleCopy);
var messageBox = document.getElementById("message-" + index);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var messageBox = document.getElementById("message-" + index);
const messageBox = document.getElementById("message-" + index);

@@ -57,15 +59,16 @@ export const Answer = ({
const handleCopy = () => {
alert("Please consider where you paste this content.");
};
document.addEventListener("copy", handleCopy);
var messageBox = document.getElementById("message-" + index);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe define "message-" + index as a variable then use it in both places

Also can use a template string

- It was being added to the whole page everytime an answer was returned
- This meant that if **any** content on the page was copied the alert was
  being shown multiple times based on how many answers there had been
- This change will mean the alert will now only be shown when an answer
  is copied and only once

Required by Azure-Samples#215
@adamdougal adamdougal force-pushed the bugfix/duplicate-copy-alert branch from 5197f25 to 384833a Compare January 30, 2024 15:32
@adamdougal adamdougal requested a review from cecheta January 30, 2024 16:54
Copy link
Collaborator

@cecheta cecheta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ross-p-smith ross-p-smith added this pull request to the merge queue Jan 30, 2024
Merged via the queue into Azure-Samples:main with commit 291223b Jan 30, 2024
2 checks passed
@adamdougal adamdougal deleted the bugfix/duplicate-copy-alert branch January 30, 2024 20:33
eduardogch pushed a commit to devopsdale/chat-with-your-data-solution-accelerator that referenced this pull request Apr 30, 2024
* Fix duplicate copy warning alert

- It was being added to the whole page everytime an answer was returned
- This meant that if **any** content on the page was copied the alert was
  being shown multiple times based on how many answers there had been
- This change will mean the alert will now only be shown when an answer
  is copied and only once

Required by Azure-Samples#215

* Address review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants