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

Provide scrollToBottom method & after command callback #36

Closed
jvorcak opened this issue Nov 15, 2018 · 8 comments
Closed

Provide scrollToBottom method & after command callback #36

jvorcak opened this issue Nov 15, 2018 · 8 comments
Assignees
Labels
enhancement New feature or request in progress Being worked on

Comments

@jvorcak
Copy link

jvorcak commented Nov 15, 2018

Hi again,

I'm trying to use this in a real application and I only have limited space to show a console.
I've set maxHeight by using contentClassName property. However now I want my console to scroll to bottom every time it's needed (after a command is executed).

For this, I'm missing some public method on a component that would

  1. Scroll console to a bottom so that I can see my prompt after each command
  2. Allows me to specify a callback that will be executed after each command (so that I can call scrollToBottom there), right now I can do it in my custom commands, but I can't do it if the command doesn't exist.

Another option is to have boolean property that will scrollToBottom after command is executed. Maybe it's worth even to have it true by default.

What do you think?

@linuswillner
Copy link
Owner

As for the scroll to bottom thing, I thought I had already implemented that feature but as it seems it got lost somewhere. The terminal is definitely intended to scroll to bottom after input. Your idea of being able to toggle it is cool too, will consider adding it.

The command callback idea is really nifty and something I should have considered initially, it’s passed by me completely. I’ll consider adding that too.

@linuswillner linuswillner added enhancement New feature or request in progress Being worked on labels Nov 15, 2018
@linuswillner linuswillner self-assigned this Nov 15, 2018
linuswillner pushed a commit that referenced this issue Nov 15, 2018
* Added command callback support and new commandCallback prop (#36)
* Added default-enabled automatic bottom scrolling on command (Disabled via new noAutoScroll prop) (#36)
* Moved utility functions to src/utils/helpers.js
* Moved styles that needn't be computed from state to src/utils/sourceStyles.js
* Moved prop types to src/utils/types.js and switched to static class field prop type declaration
@linuswillner
Copy link
Owner

linuswillner commented Nov 15, 2018

Pushed my proposed changes in accordance with this request in f2d2525. You can check out the proposed new command callback system and automatic scrolling there.

I believe this is the best of both worlds: Automatic scroll per default that can be disabled if scrolling at a later time is desired. Manual scrolling is also easy to do via the command callback, as all you need to do is to get the root element and set element.scrollTop = element.scrollHeight.

@linuswillner
Copy link
Owner

Also added live demo at https://linuswillner.me/react-console-emulator/ now.

@jvorcak
Copy link
Author

jvorcak commented Nov 20, 2018

@linuswillner I have a problem trying it on my machine in my project, can you please publish this as alpha to npm? Or you can just merge it, from what I had a look at a code it should work. I'll notify you if it's not sufficient.

@linuswillner
Copy link
Owner

linuswillner commented Nov 20, 2018

Just published version 1.7.0 to NPM. Feel free to try it out and reopen this if any issues arise 😄

@jvorcak
Copy link
Author

jvorcak commented Nov 20, 2018

screen shot 2018-11-20 at 22 00 17

With 1.7.0, I get this error, I thought it was a linking issue of mine when I tried to use it from a forked repo, but now I get it from prod. as well.

Edit: I can't re-open @linuswillner

@linuswillner linuswillner reopened this Nov 20, 2018
@linuswillner
Copy link
Owner

linuswillner commented Nov 20, 2018

Good grief, why did I not think of that... Yeah of course, it makes total sense now. It’s an issue with the build flow that is only affected by the package. I’ll fix that tomorrow, sorry about this.

I can’t issue a fix at this very moment, but a temporary fix is to obtain the utils folder from this repository and place it in the directory one level above lib/Terminal.js (As the error says) if you need to make changes quickly. Otherwise you can wait until tomorrow when I can issue a proper fix.

Sorry about the inconvenience once again.

@linuswillner
Copy link
Owner

Moving this conversation to #39.

Repository owner locked as resolved and limited conversation to collaborators Nov 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request in progress Being worked on
Projects
None yet
Development

No branches or pull requests

2 participants