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

Auto width inputs #1699

Merged
merged 5 commits into from
Jan 31, 2023
Merged

Auto width inputs #1699

merged 5 commits into from
Jan 31, 2023

Conversation

willmcgugan
Copy link
Collaborator

@willmcgugan willmcgugan commented Jan 31, 2023

Fixes #1693

Fixes a glitch where auto-width inputs were scrolled off by one character.

Screen.Recording.2023-01-31.at.12.03.08.mov

@@ -255,6 +255,7 @@ def cursor_width(self) -> int:
return self._position_to_cell(len(self.value)) + 1

def render(self) -> RenderableType:
self.view_position = self.view_position
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Forces validation again. This is required as the input may have changed size since last render.

Copy link
Contributor

Choose a reason for hiding this comment

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

How the heck does one conclude the issue was here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Forces validation again. This is required as the input may have changed size since last render.

Given that, to the casual reader, the change might look like a nop; perhaps this should be a comment in the code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@rodrigogiraoserrao The only difference with width:auto is that the size of the input changes after text is appended, leaving the view position in the wrong place. The validate_view_position should always keep the view position in the right place, so I figured i justt wasn't being called.

@davep It's somewhat of an established pattern now. Not keen on cut and pasting the same comment everywhere.

Copy link
Contributor

@rodrigogiraoserrao rodrigogiraoserrao left a comment

Choose a reason for hiding this comment

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

Don't forget to add and commit the snapshot app auto_width_input.py 😆

@@ -255,6 +255,7 @@ def cursor_width(self) -> int:
return self._position_to_cell(len(self.value)) + 1

def render(self) -> RenderableType:
self.view_position = self.view_position
Copy link
Contributor

Choose a reason for hiding this comment

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

How the heck does one conclude the issue was here?

@willmcgugan willmcgugan merged commit fc22576 into main Jan 31, 2023
@willmcgugan willmcgugan deleted the auto-width-inputs branch January 31, 2023 13:46
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.

An Input with width: auto tends to scroll the first character of its value off the left of its display
3 participants