-
Notifications
You must be signed in to change notification settings - Fork 4k
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
🚑 Quick fix prevent grammarly from running on chromium based browsers #13820
Conversation
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Thank you for opening this PR! We appreciate you! For all pull requests coming from third-party forks we will need to A Forem Team member will review this contribution and get back to |
There was a problem hiding this 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`} |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this 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!
app/javascript/crayons/MentionAutocompleteTextArea/MentionAutocompleteTextArea.jsx
Show resolved
Hide resolved
app/javascript/crayons/MentionAutocompleteTextArea/MentionAutocompleteTextArea.jsx
Outdated
Show resolved
Hide resolved
…completeTextArea.jsx Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
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 😅 ) |
These things happen 😁 |
There was a problem hiding this 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!
There was a problem hiding this 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! 🛳
What type of PR is this? (check all applicable)
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?
[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?