-
Notifications
You must be signed in to change notification settings - Fork 188
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
Fix search input #791
Fix search input #791
Conversation
Does this prevent it from occasionally erasing what was in there? |
While I wasn't able to repro that myself, I think it's due to it being overwritten as you type and the refresh happens. If that still happens after this is applied let me know. |
@@ -49,4 +49,10 @@ class View extends Backbone.View | |||
next: '<span class="glyphicon glyphicon-chevron-right"></span>' | |||
$('table.paginated').css('display', 'table'); | |||
|
|||
searchInput = $('.big-search-box') | |||
strLength = searchInput.val().length * 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why * 2
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to make sure it always ends up at the end, there's some cases where length would fail us (Opera sometimes sees a carriage return as 2 characters)
This could still have issues if the cursor is in the middle of the text -- maybe we can just get the Search box to not re-render? |
@@ -49,4 +49,10 @@ class View extends Backbone.View | |||
next: '<span class="glyphicon glyphicon-chevron-right"></span>' | |||
$('table.paginated').css('display', 'table'); | |||
|
|||
searchInput = $('.big-search-box') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small, but i would rename to $searchInput
for clarity
@tpetr Looking at the code it seems it won't be that easy. The table is a subview of the search, making it the top level element. If we don't re-render that, nothing else can. :/ |
I did some more research and found a better solution for this. Now it'll save your caret position before rendering and reset it afterwards. This will also preserve any selections as well. |
💥 thanks |
After rendering move the cursor to the end of the input and keep it focused if there is text.
@wsorenson