Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Dogusata/fix content left shift when width set to 0 temporarily #105

Merged

Conversation

dogusata
Copy link
Collaborator

@dogusata dogusata commented Sep 17, 2024

Problem

This PR resolves two issues:

1. Shifted chat contents

When you close and reopen Q panel, the contents of the active Q tab shifts to left and exceeds the left edge of the panel.

Reproduction

  • Open Q panel in VSCode
  • Type a query and hit enter
  • Close the Q panel
  • Wait until the response stream ends (you can check the output/Amazon Q to understand if the stream is finished)
  • Open the panel back
image

2. Tooltips remain on screen

When you suddenly close the Q panel while a tooltip/link preview is active and visible, when you open it back it remains on screen.

Reproduction

  • Open Q panel in VSCode
  • Get an answer with a related link on the footer of the card
  • Hover to one of the links to preview show up
  • User your keystroke to close the Q panel (for example if you're on mac and using the Q panel on right side panel use cmd+option+b to close/open it)
  • Open the panel back
  • Link preview remains on screen.
    image

Solution!

The left shift issue is caused by the width value of the html/body/main-wrapper when the Q panel is closed on VSCode since VSCode make the extensions invisible by also setting their size to 0. When the panel opens back again, the mis-calculation of the size causes the contents (mainly on flex boxes) shift to left. So we need to ensure that both body and the main wrapper has a measured width (px, em, rem, vw etc.). In addition to that, we need to make it recalculated with the width change on main wrapper.

  • Added min-width and min-height to the body if it is the root wrapper for mynah-ui
  • Added a delay 10ms animator to the main wrapper to avoid immediate calculation and misplacement
  • Added inheritance to the inner containers for the width and height values to follow the root wrapper sizing
  • Converted unnecessary flexbox to block.
  • Added @container check to turn everything's visibility off when the width is 0 (which will trigger a proper re-render when the width comes back)

For the remaining preview tooltips, when the panel is suddenly closed, the expected mouseleave and mouseout events are not being fired. Since we're also handling the element visibility with @container check now, it also removes the remaining preview tooltips as well. Which cannot be reappear unless the user hovers to the same thing again.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dogusata dogusata requested a review from a team as a code owner September 17, 2024 11:40
@dogusata dogusata merged commit 2da65a0 into main Sep 17, 2024
1 check passed
@dogusata dogusata deleted the dogusata/fix-content-left-shift-when-width-set-to-0-temporarily branch September 17, 2024 11:55
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants