-
Notifications
You must be signed in to change notification settings - Fork 21
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
Allow table to be horizontally scrollable with full-width columns #83
Comments
Yep, that's a useless table! I was starting to type up that the easiest solution would be to render the table in a horizontally scrollable view component, but I'm looking at the footer and realizing that won't work as the footer should remain static even as the rest of the table scrolls. This is a reasonable feature request, let me think about how this might work. |
I've actually implemented a pretty simple solution for it here: https://github.com/influxdata/influx-cli/pull/393/files#diff-69a5ed4eca0dfe3e0e3d0a4f8a6552f9eafe6fd6fddcac1c1199176fab421578 |
Thanks for the link! I've actually already started working on this with a similar idea of column offsets, but with a bit more visual notice that scrolling is occurring. I'm going to use shift+left and shift+right for scrolling as left/right are the default keys for paging, but that can be set through the keymap. |
I've finished the first pass of horizontal scrolling, but I want to add column freezing as well - as in your example where you always have the |
I've added horizontal freezing, so that you can freeze the first N columns, which should cover your use case if I understood your linked code above. Let me know if this is reasonable or if there's other things that need to be added for this to be useful! This has been released as It looks like Github automatically closed this issue due to one of the links I made, but I'd rather you close this yourself if you confirm that the new version solves the issue. If it doesn't, please let me know what else you think may need to be done. |
Awesome work! I do have a couple thoughts:
|
The footer thing is definitely a bug, I was focusing on all the cases where the table was larger, and not smaller... this should be fixed in #90 , will release after addressing the other issue that you posted as I was typing this as well. For getting the total width, there are some internal calculations that are done to try and track the width for caching purposes, but it's not terribly nice for exposing to the outside world. What are you trying to do? A hacky way would be to render the table and run |
For the right side carat, an easy fix is to force the alignment to be to the right. A trickier question is whether or not the column should always just be one single character wide, because this may have unexpected impacts on the footer width. Open to discussion on this one. |
I think in the name of visual and scrolling consistency, it makes sense for the caret to be one character on either side. |
I changed my mind on releasing and released I'll give this some thought of how to make the single character work while also preserving a potentially long footer as in your screenshot. |
I think I want to optimize for the table width being constant. This would add blank space at the end of the table if there are still In the meantime I'm going to go right-align the carets anyway, as I don't think there's a world where weirdly centered carets are a thing anyone wants. We can adjust later, maybe with some configuration options. I'm also going to adjust the scrolling so that it only scrolls until there's nothing left to the right, and stops. This won't fix all footer resizing issues but will at least give some help there. |
I've implemented the two things as discussed above and released as |
I think that's a good call to optimize for consistency...Although I've tried out this new version, and my keybindings for left and right aren't doing anything anymore. Not sure if I'm missing something, but I now can't scroll either direction even when the caret columns are showing. |
Were you using shift? The default keybind is shift plus arrows, but you can override that by changing the keymap. |
Shift arrows did not work, and my overrides for left and right didn't work after that either. |
Is the table set to be focused? As in myTable.Focused(true) is used when created? |
Yeah, so I was able to page up and down, but not scroll left and right. |
That’s a bit terrifying. Let me double check some things when I get some time. Are you able to run the scrolling example in this repo? |
Another question that came to mind, what version of Bubble Tea are you using? I did have to upgrade the Bubble Tea dependency in order to properly use |
Additionally, have you tried remapping the keys to something else to see if that might work? |
Ok, I've figured out that remapping is causing problems but I can get the scrolling working back with version 0.13.1. If I have no Then when I upgrade to 0.13.2, the same code doesn't work anymore. |
Oof. I had trouble making that particular function work smoothly, and I thought I had fixed the edge cases but it's likely you're running into that. Could you give me the dimensions of the table you're using so I can test locally? As in, column widths and which are frozen? |
I've tested a bit with the keybindings and they seem to work all right, but I may have a clue as to what's happening with your situation. It's important to note that rebinding them to I've passed in the default keybindings with |
I've fixed the keymap behavior to properly run all actions instead of short-circuiting, so your |
I finally got a good excuse to try out fuzzing, and it helped me find the edge cases you were likely running into. I was doing an incorrect calculation regarding the frozen first column, which has been removed and now the fuzzer seems quite happy with all kinds of permutations. Try |
Glad to hear! I'll try it out a little later today and let you know. |
Alright, I've come back and found that it works! Thanks for your diligence on this. |
There should be a way to disallow columns being truncated like this, and instead allow the table to stretch horizontally offscreen, which would then be able to be scrolled left and right with the arrow keys. There's an example output below for a table with many columns where truncation makes the table pretty much useless.
The text was updated successfully, but these errors were encountered: