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 issue #13699: fix response tooltip misplaced and image doesn't show up #20147

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

ana-mc-almeida
Copy link

@ana-mc-almeida ana-mc-almeida commented Apr 10, 2024

Overview

  1. This PR fixes Full interaction response tooltip misplaced for graph input interaction (and the image doesn't show up) #13699.
  2. This PR does the following: The tooltip is now aligned with the short interaction response that the user clicks on to show the tooltip, and it fixes the issue of the graph not appearing within that tooltip.
  3. The original bug occurred because: The tooltip was being called within the parent div of the short interaction response.

Essential Checklist

Please follow the instructions for making a code change.

  • I have linked the issue that this PR fixes in the "Development" section of the sidebar.
  • I have checked the "Files Changed" tab and confirmed that the changes are what I want to make.
  • I have written tests for my code.
  • The PR title starts with "Fix #bugnum: " or "Fix part of #bugnum: ...", followed by a short, clear summary of the changes.
  • I have assigned the correct reviewers to this PR (or will leave a comment with the phrase "@{{reviewer_username}} PTAL" if I can't assign them directly).

Proof that changes are correct

Before:
Screenshot_20240410_133825

After:
Screencast_20240410_132208.webm
As requested by @seanlip in the discussion of issue #13699, the video also includes proof that other types of interactions (such as drag-and-drop) are functioning properly.

Proof of changes in Arabic language

Screenshot_20240410_132535

PR Pointers

Copy link

oppiabot bot commented Apr 10, 2024

Assigning @Lawful2002 for the first pass review of this PR. Thanks!

Copy link

Hi! @ana-mc-almeida Welcome to Oppia! Could you please follow the instructions here and sign the CLA Sheet to get started? You'll need to do this before we can accept your PR. Thanks!

@ana-mc-almeida
Copy link
Author

@seanlip PTAL

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @ana-mc-almeida! Left a couple of notes. Also could you please look at the failing CI checks?

@seanlip seanlip assigned ana-mc-almeida and unassigned seanlip Apr 12, 2024
@seanlip
Copy link
Member

seanlip commented Apr 12, 2024

Also @ana-mc-almeida one other question. Could you avoid the reader having to scroll the graph in the response? (I looked at your video.)

Also how does the behaviour on mobile look like?

Thanks!

@ana-mc-almeida
Copy link
Author

ana-mc-almeida commented Apr 14, 2024

Hi @seanlip, thanks for your reply!

Also @ana-mc-almeida one other question. Could you avoid the reader having to scroll the graph in the response? (I looked at your video.)

I had also thought about this and even commented a proposed solution in the issue, but after testing the interactions, I noticed that it couldn't be done because it would affect the lessons already created since it depends on the position where the graph starts to be drawn.
Example:

  • with GRAPH_INPUT_LEFT_MARGIN: 120
    Screenshot_20240414_145911
  • with GRAPH_INPUT_LEFT_MARGIN: 200
    Screenshot_20240414_150123

Let me know if you think there's any other way to do this.

Also how does the behavior on mobile look like?

Screenshot_20240414_145456

Thank you in advance for your time.

@seanlip
Copy link
Member

seanlip commented Apr 16, 2024

@ana-mc-almeida Some thoughts -- perhaps you could determine the bounding box for the graph by looking at the coordinates of the vertices in it, and that will tell you what to show. Another option could be to show the full size of the graph canvas but "zoomed out" so that it's smaller (but still rectangular). I think both of those approaches would generalize for all the graphs, would any of the approaches work?

@ana-mc-almeida
Copy link
Author

Hi @seanlip, sorry for the late reply and thanks for your help.

I think I have found a solution to remove the unnecessary whitespace that was causing users to have to scroll on the graph, but I would like to have your opinion on the way I'm doing it before committing the changes.

I followed your suggestion to check the coordinates of the graph vertices, and thus I am finding the vertex with the smallest X and only drawing from there. In the case of a labeled graph, it is also necessary to consider the labels. Below are screenshots of the changes:

Screenshot_20240420_133423
Screenshot_20240420_133348
Screenshot_20240420_133325

This way, we end up with these graphs:

Screenshot_20240420_132448
Screenshot_20240420_132342
Screenshot_20240420_132533

  • Proof of changes in Mobile
    Screenshot_20240420_132908

  • Proof of changes in Arabic language:
    Screenshot_20240420_132832

Please let me know if this is the result you were expecting.

@seanlip
Copy link
Member

seanlip commented Apr 20, 2024

@ana-mc-almeida Generally speaking, the results in the pop-ups look fine, except that the whole point of this was to remove the scrollbars in the pop-ups, either by cropping or by shrinking the image or by making the pop-up a bit bigger. Could that be fixed?

Also, for drag-and-drop, you might want to remove the whitespace on the left in the pop-up. Otherwise it would not look great if the choices were longer.

Thanks!

@ana-mc-almeida
Copy link
Author

@seanlip, sorry for misunderstanding.

However, I'm not understanding the goal of removing the scrollbars: increasing the size of the popup may lead to other problems, especially on mobile, and reducing the graph could make it illegible.

In your opinion, how should the popup look for the following graph?

Screencast_20240420_154402.online-video-cutter.com.mp4

I apologize deeply for this confusion.

@seanlip
Copy link
Member

seanlip commented Apr 20, 2024

@ana-mc-almeida In my opinion, the graph should be zoomed out so that a smaller version shows in the popup without scrollbars. Or the popup should be bigger so that it doesn't have scrollbars.

Copy link

oppiabot bot commented Apr 27, 2024

Hi @ana-mc-almeida, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added the stale label Apr 27, 2024
@ana-mc-almeida
Copy link
Author

@seanlip apologies for the delayed response, I was facing some difficulties, but I believe I've managed to sort them out.
Take a look and let me know what you think:

  • Labeled graph
    Screenshot_20240428_152709
  • Unlabeled graph that doesn't need resizing
    Screenshot_20240428_152755
  • Unlabeled graph that needs resizing
    Screenshot_20240428_152813
  • Mobile:
    Screenshot_20240428_160536
  • Arabic language:
    Screenshot_20240428_160604

@oppiabot oppiabot bot removed the stale label Apr 28, 2024
@seanlip
Copy link
Member

seanlip commented Apr 28, 2024

@ana-mc-almeida Your screenshots look good to me. Thanks for checking!

@ana-mc-almeida
Copy link
Author

ana-mc-almeida commented May 4, 2024

Hi @seanlip, I've already added tests related to the code changes that allow the graphs resize.
Right now, I'm failing an end-to-end test, but I don't think it has anything to do with the changes I made. Could you PTAL?
Thank you!

@oppiabot oppiabot bot assigned seanlip and unassigned ana-mc-almeida May 4, 2024
Copy link

oppiabot bot commented May 4, 2024

Unassigning @ana-mc-almeida since a re-review was requested. @ana-mc-almeida, please make sure you have addressed all review comments. Thanks!

@seanlip
Copy link
Member

seanlip commented May 9, 2024

@ana-mc-almeida Sorry for the late reply. Yup, this is a known flake: #19732. I'll restart the failing test.

In general, if a CI check fails in future, please check the existing issues to see whether it's been reported. If so, link to that issue and ask for a re-run. If not, then the error might be due to your PR or a new issue might need to be filed.

Thanks!

@@ -57,6 +57,7 @@ export class InteractionDisplayComponent {

ngAfterViewInit(): void {
this.buildInteraction();
this.changeDetectorRef.detectChanges();
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain (for posterity) why this change was needed?

Copy link
Author

Choose a reason for hiding this comment

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

I had already justified this here, but now that I've looked back at the code, I think it's not necessary since the changes are already being detected within the buildInteraction(). I'll remove it.


var maxY = this.getMaxY();
if (this.HEIGHT < maxY) {
scale = this.HEIGHT / (maxY + this.MIN_LEFT_MARGIN);
Copy link
Member

Choose a reason for hiding this comment

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

Why are we comparing height to MIN_LEFT_MARGIN ... shouldn't it be MIN_TOP_MARGIN or similar?

Copy link
Author

Choose a reason for hiding this comment

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

Sorry, you're absolutely right. This name stems from previous changes where only left margin was used. I'll change the name to MIN_MARGIN since it's being used everywhere there's resizing to maintain consistency.

Copy link
Member

Choose a reason for hiding this comment

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

Hm, just to check, conceptually why is the min left margin equal to the min top margin?

Copy link
Author

Choose a reason for hiding this comment

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

I only saw your response after committing the changes, I apologize. I'll change it if you think it's necessary. However, I decided to make the margins equal purely for aesthetic reasons, as I believe it looks better than having the graph just with left margin.

Copy link
Member

Choose a reason for hiding this comment

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

OK, do we use these as right and bottom margins too?

If not, you can call it MIN_LEFT_AND_TOP_MARGIN; we can split it out later if needed.

Copy link
Member

Choose a reason for hiding this comment

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

Wait, actually .. I suppose it's kind of weird to only have a margin on the top and the left. How do you ensure that the graph doesn't extend too far to the right or bottom?

Copy link
Author

Choose a reason for hiding this comment

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

Because when that happens, I'm resizing the graph.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry @ana-mc-almeida, I still don't get it.

What is the exact definition of MIN_MARGIN? What does it represent, exactly?

Conceptually, I would have expected to see the bounding box computed based on something like (maxX - minX) + padding and similar for Y. Not saying what you've done is wrong, just that I don't understand it -- I'm trying to better understand why we are treating e.g. the left vs right margins differently. Can you elaborate a bit more on the math behind your approach?

Copy link
Author

Choose a reason for hiding this comment

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

@seanlip sorry for the delay in responding, I will walk through my thought process to see if I can answer your questions:

The first thing I do to avoid the scrollbar appearing is to remove the white space to the left of the graph. Here arises the first necessity of using the MIN_MARGIN: I want to leave a small space so that the nodes are not completely at 0, as it appears here:

Screenshot_20240519_140842

In this way, I am setting the default value of MIN_MARGIN = 10. However, for Arabic languages, the label appears before the node, so it is necessary for the MIN_MARGIN to vary according to the label in the case of a labeled graph.

After removing the white space, if it is still necessary to reduce the image, it is necessary to obtain the scale. Here, to avoid the graph becoming disproportionate, I will calculate the scale for both height and width. Again, because of the labels (this time for English, for example), it is necessary to consider the already calculated MIN_MARGIN. To ensure consistent scaling (without the graph becoming disproportionate), I use the margin for both the height and width scaling.

I don't think this variable can be exactly considered as padding because, if it were, either the size of the popup would vary, or the graph would become disproportionate.

I think I have explained the entire thought process behind my code, especially how I am resizing the graph so that it does not extend too much to the right or downwards, but if you still have doubts, I will try other ways to explain my code.

I apologize for the delay in responding; I was unable to use my computer for a few days and ended up being quite overwhelmed with university and work. I also had to take extra time to do some manual tests to see how the graphs would look if I were calculating this margin in a different way and I really believe this is the best solution.

While doing these tests, I realized that I can also remove the extra white space at the top, and the graphs now look like this:

Screenshot_20240519_142948
Screenshot_20240519_142846

Initially, this was not done because there was no need to remove the vertical scroll, but I think this way the graph looks even better. I hope this doesn't confuse you even more regarding the initial doubts about why the MIN_MARGIN is necessary, but let me know if you want me to implement this.

Once again, sorry for this confusion and, even worse, for the delay in responding, and thank you very much for your attention with this issue.

@seanlip seanlip assigned ana-mc-almeida and unassigned seanlip May 9, 2024
Copy link

oppiabot bot commented May 17, 2024

Hi @ana-mc-almeida, I'm going to mark this PR as stale because it hasn't had any updates for 7 days. If no further activity occurs within 4 days, it will be automatically closed so that others can take up the issue.
If you are still working on this PR, please make a follow-up commit within 4 days (and submit it for review, if applicable). Please also let us know if you are stuck so we can help you!

@oppiabot oppiabot bot added stale and removed stale labels May 17, 2024
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.

Full interaction response tooltip misplaced for graph input interaction (and the image doesn't show up)
3 participants