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

🚑 Quick fix prevent grammarly from running on chromium based browsers #13820

Merged

Conversation

Link2Twenty
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Grammarly was preventing users from writing posts, while using chromium, this patch prevents grammarly from running in chromium browsers

Related Tickets & Documents

partial #13814

QA Instructions, Screenshots, Recordings

N/A

UI accessibility concerns?

Grammarly is a useful tool for dyslexic people if we can get it working we should

Added tests?

  • Yes
  • No, and this is why: old tests will still work
  • I need help with writing tests

[optional] Are there any post deployment tasks we need to perform?

N/A

[optional] What gif best describes this PR or how it makes you feel?

Mr Bean rushes to get ready, drinks tea straight from teapot

@Link2Twenty Link2Twenty requested a review from a team May 20, 2021 17:46
@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label May 20, 2021
@Link2Twenty Link2Twenty requested review from nickytonline and jacobherrington and removed request for a team May 20, 2021 17:46
@github-actions
Copy link
Contributor

Thank you for opening this PR! We appreciate you!

For all pull requests coming from third-party forks we will need to
review the PR before we can process it through our CI pipelines.

A Forem Team member will review this contribution and get back to
you as soon as possible!

nickytonline added a commit that referenced this pull request May 20, 2021
Copy link
Contributor

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

@Link2Twenty, thanks so much for the fix. I have a different approach that builds off of what you've done which I mention in the comments.

Looking forward to seeing this in production!

@@ -391,6 +392,7 @@ export const MentionAutocompleteTextArea = forwardRef(
<ComboboxList>
{users.map((user) => (
<ComboboxOption
key={`${user.username}_key`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick (non-blocking): Adding _key isn't necessary. They key as user.username is already unique and not related to this fix.

@@ -43,6 +43,7 @@ export const EditorBody = ({
onChange,
defaultValue,
switchHelpContext,
disableGrammarly,
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor (blocking): Create a function for the Grammarly data attribute and avoid prop drilling.

There are two spots where we need to disable Grammarly. The title and body of a post in the editor and hopefully this code can be removed in the near future (assuming Grammarly fixes whatever they changed or implements it in a different manner). As well, we don't want the <MentionAutoCompleteTextArea /> to be aware of Grammarly. We can just pass in the additional props and spread them.

It would take too long to comment on the PR so I created a branch to demonstrate what I'm proposing. See https://github.com/forem/forem/tree/nickytonline/poc-disable-grammarly.

In my linked POC branch I made it a hook, but it just needs to be a function, not a hook.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a third place we need to disable it too - the connect chat box is showing the same issues

@@ -18,12 +18,16 @@ export const Form = ({
switchHelpContext,
errors,
}) => {
// 🚑 Detect if user is using chromium to disable grammarly
const isChrome = !!window.chrome;
Copy link
Contributor

Choose a reason for hiding this comment

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

This check will also return true for all Chromium-based browsers which we don't want as Grammarly currently works in at least Edge (Chromium). We could combine this check with a regex test on the user-agent, e.g.

!/(Chrome\/.+Edg\/)|/.test(navigator.userAgent)

I haven't checked the Brave user-agent or others, but we could add them in the regex.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that regex may be incorrect

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I tested it yesterday in Chrome, Edge, and Firefox and it seem to behave properly. I'm using .+ in the middle as there is a lot in the user-agent string. I can help with this if it's blocking you.

@pr-triage pr-triage bot added PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes and removed PR: unreviewed bot applied label for PR's with no review labels May 20, 2021
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels May 21, 2021
Copy link
Contributor

@aitchiss aitchiss left a comment

Choose a reason for hiding this comment

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

I gave this a quick spin and it seems to all be working as hoped, I just had a few very minor change requests but otherwise looks great 👍 Thanks for taking this on!

@pr-triage pr-triage bot removed the PR: unreviewed bot applied label for PR's with no review label May 24, 2021
@pr-triage pr-triage bot added the PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes label May 24, 2021
…completeTextArea.jsx

Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
@pr-triage pr-triage bot added PR: unreviewed bot applied label for PR's with no review and removed PR: reviewed-changes-requested bot applied label for PR's where reviewer requests changes labels May 24, 2021
@aitchiss
Copy link
Contributor

Hey @Link2Twenty - something we've just become aware of is that even when Grammarly appears to "work" in Firefox / non-Chrome browsers, it's not consistently allowing insertion of Grammarly's suggestions, and is just generally causing weirdness.

We missed that before, but given it's behaving in a 'broken' way on all browsers, it's probably best that we simplify this PR and just add the relevant attribute inline to the various textareas (without the need to check if we're in Chrome / have a separate function).

Sorry for the confusion - it seems we all tested that Grammarly was making suggestions/highlighting, but we didn't check that suggestions were being inserted correctly (woops 😅 )

@Link2Twenty
Copy link
Contributor Author

These things happen 😁
I've changed everything over to just being hard coded now.

Copy link
Contributor

@aitchiss aitchiss left a comment

Choose a reason for hiding this comment

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

Tested this out locally on a few browsers and all worked OK despite having Grammarly running.

We'll need to keep an eye on this / explore more under #13814 as Grammarly is such a useful tool and we definitely only want this to be a temporary patch!

@pr-triage pr-triage bot added PR: partially-approved bot applied label for PR's where a single reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels May 24, 2021
Copy link
Contributor

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @Link2Twenty! LGTM! 🛳

@nickytonline nickytonline merged commit 61cd4b3 into forem:main May 25, 2021
@pr-triage pr-triage bot added PR: merged bot applied label for PR's that are merged and removed PR: partially-approved bot applied label for PR's where a single reviewer approves changes labels May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: merged bot applied label for PR's that are merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants