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 12 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 27, 2024

Hi @seanlip I'm failing an end-to-end test and I think it's a known flake: #19732 . I already commented here, could you PTAL and re-run the test? Thanks!

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

oppiabot bot commented May 27, 2024

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

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! Looks awesome :) Just trivial comment fixes and then it's good to go!

// The minimum margin to the left and top of the display.
// The first vertex should be at (MIN_MARGIN, MIN_MARGIN).
// This value should not be 0 because only half of the vertex will be shown.
MIN_MARGIN: number = 10;
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 make this MIN_MARGIN_PX (or whatever units it is)?

Copy link
Author

Choose a reason for hiding this comment

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

Done

return this.MIN_MARGIN;
}
// If the graph is labeled, the labels size should be taken into account
// because in arabic, the labels will be shown on the left side of the vertex.
Copy link
Member

Choose a reason for hiding this comment

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

Capitalize "Arabic".

Copy link
Author

Choose a reason for hiding this comment

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

Done

if (!graph.isLabeled) {
return this.MIN_MARGIN;
}
// If the graph is labeled, the labels size should be taken into account
Copy link
Member

Choose a reason for hiding this comment

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

labels size --> "label's size" or "label sizes"

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -58,6 +64,73 @@ export class ResponseGraphInput {
) as GraphAnswer;
this.VERTEX_RADIUS = this.graphDetailService.VERTEX_RADIUS;
this.EDGE_WIDTH = this.graphDetailService.EDGE_WIDTH;

this.MIN_MARGIN = this.graphDetailService.getMinMargin(this.graph);
Copy link
Member

Choose a reason for hiding this comment

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

Prefer MIN_MARGIN_PX

(probably should do it for the other constants above too, but OK to skip if you don't want to)

Copy link
Author

Choose a reason for hiding this comment

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

Done. I also changed the variables VERTEX_RADIUS and EDGE_WIDTH to VERTEX_RADIUS_PX and EDGE_WIDTH_PX, respectively.

return Math.max(...this.graph.vertices.map(vertex => vertex.y));
}

// This function calculates the scale factor required to fit 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.

...to fit the graph within the display area.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@oppiabot oppiabot bot unassigned seanlip May 27, 2024
Copy link

oppiabot bot commented May 27, 2024

Unassigning @seanlip since the review is done.

Copy link

oppiabot bot commented May 27, 2024

Hi @ana-mc-almeida, it looks like some changes were requested on this pull request by @seanlip. PTAL. Thanks!

@ana-mc-almeida
Copy link
Author

Hi @seanlip PTAL

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

oppiabot bot commented May 29, 2024

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

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.

HI @ana-mc-almeida, could you please respond to all review comments, as explained in the PR guidelines? Please don't resolve comments directly, it makes it hard for reviewers because they have to open each comment to get the context.

Please fix this and then request review again. Thanks!

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

Sorry @seanlip, I've already unresolved and responded to all comments. Could you PTAL? Thanks!

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

oppiabot bot commented May 29, 2024

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

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.

LGTM. Thanks @ana-mc-almeida !

@seanlip seanlip enabled auto-merge May 30, 2024 17:10
@seanlip seanlip assigned lkbhitesh07 and unassigned seanlip May 30, 2024
@seanlip
Copy link
Member

seanlip commented May 30, 2024

@Lawful2002 @lkbhitesh07 PTAL for codeowners, thanks.

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)
4 participants