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

SPIKE: How to fix overlapping UI elements in bootstrap wizard if height of terminal window is insufficient #2831

Closed
opudrovs opened this issue Oct 4, 2022 · 2 comments
Assignees

Comments

@opudrovs
Copy link
Contributor

opudrovs commented Oct 4, 2022

Text inputs or git providers table in the bootstrap wizard in gitops run are mangled if the height of the terminal window is insufficient.

Examples of "mangled" or overlapping elements if terminal window is too low:

Screenshot 2022-10-04 at 23 07 01

Screenshot 2022-10-05 at 00 46 25

Resizing the window to increase the terminal height fixes the issue:

Screenshot 2022-10-04 at 23 08 30

Screenshot 2022-10-05 at 01 07 10

Supposedly, adding a Bubble Tea viewport component around the UI elements should fix this issue and make the UI reserve space for inputs. How to set viewport height in this case properly (and if it needs to be set to a fixed value at all) and make it adapt to different number of flag text inputs for different git providers requires further research.

@opudrovs opudrovs self-assigned this Oct 4, 2022
@opudrovs opudrovs added severity/medium low < medium < high < critical and removed exclude from release notes labels Oct 4, 2022
@opudrovs opudrovs changed the title Text inputs in the bootstrap wizard in gitops run are mangled if the height of the terminal window is insufficient Fix overlapping UI elements in bootstrap wizard if height of terminal window is insufficient Oct 4, 2022
@opudrovs
Copy link
Contributor Author

opudrovs commented Oct 5, 2022

The initial simple fix (wrapping controls with a viewport of fixed height) didn't work. It looks like it's a complex issue with displaying more lines than the terminal window height. So, this issue requires more research. I plan to return to it later.

@ozamosi ozamosi changed the title Fix overlapping UI elements in bootstrap wizard if height of terminal window is insufficient SPIKE: Fix overlapping UI elements in bootstrap wizard if height of terminal window is insufficient Oct 18, 2022
@opudrovs
Copy link
Contributor Author

opudrovs commented Oct 20, 2022

I've decided to retry the viewport fix from scratch, created a basic prototype based on the Bubble Tea pager example and copied most of inputs from the bootstrap wizard there. So, for the prototype the viewport prevents the inputs from being mangled if the terminal height is insufficient (probably in the original fix the viewport height was not set correctly):

Screen.Recording.2022-10-19.at.18.19.58.mov

When using arrow buttons to scroll up and down, if the terminal height is insufficient (in the first part of the video), the UI controls look as expected (I have not copied the entire text inputs style on focus/blur code, but the basic code works fine).

Only when using the terminal scrollbar to scroll, the previous rendered part of the UI disappears until redrawing is forced with either up or down arrow or mouse wheel scrolling (which resents the terminal scrollbar position to the bottom).

As @ozamosi said,

You can't affect the terminal's scroll bars - they're part of the terminal itself, whereas the program is running in a TTY. Imagine the program as a java applet or a flash animation, and the user clicked the back button.

I think the APIs were designed for the terminal "window" to be a printer and the "contents" to just be paper :thinking_face: Bubbletea's rendering is basically just to hit backspace until it's at the top left corner, and then echoes a full screen of characters.

I also came across some issues related to weird scrollbars behavior and redrawing content in the terminal (when using alt a screen buffer/alt screen):

charmbracelet/bubbletea#349
xtermjs/xterm.js#802

So, the issue with the screen not repainted when scrolling the terminal window with system scrollbars is by design and not a Bubble Tea bug.

To solve the original issue with overlapping inputs, we'll wrap them in a Bubble Tea viewport component and switch to using Up and Down arrow keys only for scrolling (scrolling the viewport with arrow keys or mousewheel is enabled for the viewport by default, we'll just need to remove using arrow keys for navigating between inputs) while only Tab and Shift + Tab will be used for navigating between inputs. Some other minor adjustments of Bubble tea message processing might be needed. The issue will be solved in #2920

Known limitations: Viewport is sized based on Bubble Tea's WindowSizeMsg, and this message is not available on Windows. But we do not support Windows officially for CLI anyways.

@opudrovs opudrovs added type/spike and removed bug Something isn't working severity/medium low < medium < high < critical labels Oct 20, 2022
@opudrovs opudrovs changed the title SPIKE: Fix overlapping UI elements in bootstrap wizard if height of terminal window is insufficient SPIKE: How to fix overlapping UI elements in bootstrap wizard if height of terminal window is insufficient Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant