Skip to content

fix: Align answer submission notification to bottom of viewport if out of view#27022

Merged
davidjoy merged 1 commit intoopenedx:masterfrom
open-craft:arjun/bb-3828-alignment
Jun 30, 2021
Merged

fix: Align answer submission notification to bottom of viewport if out of view#27022
davidjoy merged 1 commit intoopenedx:masterfrom
open-craft:arjun/bb-3828-alignment

Conversation

@arjunsinghy96
Copy link
Contributor

@arjunsinghy96 arjunsinghy96 commented Mar 16, 2021

Description

This PR changes the alignment of answer submission notification. Currently the notification is aligned vertically centred if not in viewport. This behaviour was observed in Chrome browser (87+). The alignment was correct when tested on Mozilla Firefox (86.0)

JIRA Tickets: BB-3828

Sandbox URL: TBD

Screenshots

Before
before-pr

After:
after

Testing instructions

  1. Get the master devstack running
  2. Sign in to LMS
  3. Open Exam section of Demo Course.
  4. Answer questions and click on Submit button.
  5. Verify that the notification is scrolled to the centre of the viewport when not in viewport.
  6. With notification in centre of viewport, submit another answer.
  7. Verify that page does not scroll.
  8. Now checkout to this branch and perform the same tests after restarting the LMS server
    a. Verify that the notification is scrolled to the bottom of the viewport when not in viewport.
    b. With notification in viewport, submit another answer
    c. Verify that the page does not scroll.

Deadline

None

Reviewers

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Mar 16, 2021
@openedx-webhooks
Copy link

Thanks for the pull request, @arjunsinghy96! I've created OSPR-5673 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@Agrendalath
Copy link
Member

jenkins run a11y

1 similar comment
@viadanna
Copy link
Contributor

jenkins run a11y

@natabene
Copy link
Contributor

@arjunsinghy96 Thank you for your contribution. Please let me know once it is ready for our review.

@arjunsinghy96
Copy link
Contributor Author

jenkins run a11y

@natabene natabene changed the title Fix answer notification alignment to bottom Fix answer notification alignment to bottom Apr 2, 2021
@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Apr 2, 2021
Copy link
Member

@Agrendalath Agrendalath left a comment

Choose a reason for hiding this comment

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

@arjunsinghy96, I found some typos. I haven't checked the code.
cc: @viadanna

@arjunsinghy96 arjunsinghy96 force-pushed the arjun/bb-3828-alignment branch from b7b4835 to ac9a679 Compare April 30, 2021 14:05
@arjunsinghy96 arjunsinghy96 force-pushed the arjun/bb-3828-alignment branch from 935d2cb to f471bc1 Compare May 10, 2021 13:36
@arjunsinghy96
Copy link
Contributor Author

@natabene Thanks for the patience. This PR is now ready for edx review.

@viadanna
Copy link
Contributor

Good to go 👍

  • I tested this on my devstack.
  • I read through the code.

@natabene
Copy link
Contributor

natabene commented Jun 1, 2021

@sarina This is ready for your team to review.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a small thing, but if you reverse the clauses in this conditional then you won't do the viewport calculation for anything except the notification-btn. If there are a lot of elements, it could reduce the work being done here.

if (elem.classList.contains('notification-btn') && !isInViewport(elem)) {

That'll short circuit if the element's class list doesn't contain notification-btn, avoiding the call to isInViewport.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have a sense of how often this focus function is called? It seems like we're overriding it for all calls on this page... I'd just want to sanity check that we're not adding a whole bunch of processing to the page when we loop through this.each below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidjoy Thanks for the review and suggestion. I am working on it this week.

Do you have a sense of how often this focus function is called?

I will try to get some metric on this and update you by end of the week.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidjoy Following is the frequency of focus function calls:

  1. focus is called twice when rendering the sequence i.e by Sequence.render. It is called on first render of page as well as whenever the active sequence is changed by clicking on Next, Previous or the sequence button.
  2. focus is called twice for each Problem in the xblock when rendering. So, if the sequence has n problems, focus will be called n*2 times.
  3. focus is called once when rendering discussions on the sequence (xblock).
  4. focus is called twice for videos in the sequence (xblock)
  5. For staff users, focus is called once when rendering the staff toolbar on top of the page.

Additionally, focus is called twice by calculator.js on first render of the page.

Please let me know you further thoughts.


I tried attaching a delegated (ref) event handler on .notification-btn but the browser behaviour was preceded by the event handler callback. The notification was already moved to centre of page before the callback function ran.

Copy link
Contributor

@davidjoy davidjoy left a comment

Choose a reason for hiding this comment

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

Had a suggestion and a question. In general this looks like an improvement, just want to be cautious of any overhead we're adding!

@arch-bom-gocd-alerts
Copy link

📣 💥 Heads-up: You must either rebase onto master or merge master into your branch to avoid breaking the build.

We recently removed diff-quality and introduced lint-amnesty. This means that the automated quality check that has run on your branch doesn't work the same way it will on master. If you have introduced any quality failures, they might pass on the PR but then break the build on master.

This branch has been detected to not have commit 2e33565 as an ancestor. Here's how to see for yourself:

git merge-base --is-ancestor 2e335653 arjun/bb-3828-alignment && echo "You're all set" || echo "Please rebase onto master or merge master to your branch"

If you have any questions, please reach out to the Architecture team (either #edx-shared-architecture on Open edX Slack or #architecture on edX internal).

@natabene natabene removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Jun 15, 2021
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
@arjunsinghy96 arjunsinghy96 force-pushed the arjun/bb-3828-alignment branch from f471bc1 to c9e6043 Compare June 21, 2021 13:03
@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@davidjoy
Copy link
Contributor

This looks good - I tested it and it's a definite improvement. 👍🏻

Waiting for checks to finish and will then merge it.

@davidjoy davidjoy changed the title Fix answer notification alignment to bottom fix: Align answer submission notification to bottom of viewport if out of view Jun 30, 2021
@davidjoy davidjoy merged commit 52ab785 into openedx:master Jun 30, 2021
@openedx-webhooks
Copy link

@arjunsinghy96 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

@Agrendalath Agrendalath deleted the arjun/bb-3828-alignment branch June 30, 2021 19:05
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been rolled back from the production environment.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

blarghmatey pushed a commit to mitodl/edx-platform that referenced this pull request Aug 2, 2021
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request Nov 25, 2021
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
(cherry picked from commit 52ab785)
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request Jan 20, 2022
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
(cherry picked from commit 52ab785)
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request May 12, 2022
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
(cherry picked from commit 52ab785)
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request Jun 7, 2022
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
(cherry picked from commit 52ab785)
Agrendalath pushed a commit to open-craft/openedx-platform that referenced this pull request Jun 7, 2022
On focus to the answer submition notification, the
notification was scrolled to center of screen. This
behaviour was on Chrome(87+) browser.
This commits overrides the focus jQuery plugin to
set the alignment of answer notifications to the bottom of the
viewport.

Fix the custom focus jQuery plugin

Co-authored-by: Agrendalath
(cherry picked from commit 52ab785)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged open-source-contribution PR author is not from Axim or 2U

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

Comments