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

Bugfix and vital features Fork #575

Closed
wants to merge 6 commits into from
Closed

Conversation

Svakinn
Copy link

@Svakinn Svakinn commented Dec 26, 2013

Hi there.
I would like to share with you a new fork with critical bug fixes and much requested features for typeahead.
Since the list of modifications is quite long I do not expect this pull to be accepted as is. The intention is more or less to supply a temporary solution for the control until the release of the next version. Also the code here could be useful for developers of the new version.

The short list of updates is here:

  1. Critical bugfix - IE11 problems caused by failed browser detection.
  2. Bugfix - Mouse-click on dropdown selection caused focus and blur events to occur on the input control.
  3. Critical Bugfix - Local data suggestion search broke on suggestions that had space in the display name.
  4. New urgent feature - Allowing for custom, on-demand data retrieval without direct Ajax call.
  5. New urgent feature - Not to require display names to be unique
  6. New urgent feature - Getting control over the internal cache for remote data
  7. Much requested basic feature - Get some handle on when customer exits input box without picking name from the suggestion list.
  8. Requested basic feature Get suggestions before typing starts.
  9. New feature - Simplified initialization - suggestion search triggering (on demand)
  10. New feature - Busy indication
  11. A must for myself. - Nicely working Knockout Binding Handler, simplifying the set-up of the control and data-binding to the typed text, the selected datum and the suggestion data.

More detailed list of update is available here: https://github.com/Svakinn/typeahead.js/blob/typeaheadSimple/New.md
The new Readme.md is here: https://github.com/Svakinn/typeahead.js/blob/typeaheadSimple/README.md

RELATED ISSUES:
I took a quick look at open issues for the last 5 months and it seems that the changes in this fork, are related to or address the following issues:

  1. Bugfix: IE11 problems
    Function isMsie does not work in IE11 #557-nathankoop/Click on dropdown item misbehaves in IE #554-svakinn

  2. Bugfix: Blur/Focus flickering
    how to prevent AJAX requests when user selects an item #548-chrisdlangton, Clicking outside dropdown list doen't hide this dropdown #539-rtjm, Use the silent option when setting the input from a selection. #460-jaurand

  3. Bugfix: Local data search
    some result not shown dropdown #484-b4umel, how to search for any of token not all of them? #461-vinograd19

  4. Custom data retrieval
    Add an option to remote object called 'handler' to allow custom functions for remote #556-cusspvz, Using google maps autocomplete with typeahead js #536-harry2607, Missing callbacks / events for server communication started / stopped #518-dwt, Support local being a function #485-ansman, Added support of custom transport #473-speedblue

  5. Keys & display names
    Unique field? #547-narrowfail, add optional nameKey for input value display #546-ryanpitts, VALUE and OPTION like SELECT field #534-Venu85, Return custom display key instead of default value on Input selection. #523-jdaily, Support relational lookups #496-nikmartin, Add support for displaying duplicates, disable fetching suggestions after accepting a suggestion #481-davismj, Records with same value key #459-davidmturner

  6. Caching control
    A flag to prevent caching #562-krazyjakee, Store prefetch data source unique to the end-point #549-chrisdlangton, AJAX Post Calls #542-jasonterando, Add public method to clear all dataset requestCaches. #521-jgerigmeyer, Add refreshCache method and new event dropdownOpened. #515-tellex, local storage stores old data #501-PrimoZvanut, Many typeahead instances on one page are not working correctly. #492-jpbecotte, create cache clearing mechanism #476-dtudury, Remote dataset caches only on url #455-cusspvz

  7. Selection verification
    Passing through the fetched data to closed event triggering #566-zhigang1992, Added 'matched' and 'mismatched' custom events on blur #530-ambahk, Need to fire custom event when user types out a suggestion, but doesn't "select" or "autocomplete" #526-ahodges13, Adding force selection option to typeAhead (enhancement) #512-PetrSnobelt

  8. Auto suggestion option
    show all possible options on focus #550-netcult, Showing default suggestions on focus if minLength is 0 #390-theoephraim

Merry Christmas !!

@jharding
Copy link
Contributor

Thanks for doing this. I apologize for my prolong absence, hopefully it won't happen again.

Due to the nature of this pull request, I most likely won't merge it in, but I'll make sure the majority of your fixes make their way to the next official release of typeahead.js.

@Svakinn
Copy link
Author

Svakinn commented Dec 27, 2013

Exellent 👍
I would though suggest that you fix the IE11 bug in the current release:
isMsie: function () { return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false; },

New feature -Simplified initialization - suggestion search triggering
(on demand)
New feature - Busy indication
@Svakinn
Copy link
Author

Svakinn commented Dec 30, 2013

2 new featues added:
Simplified initialization
One of the most annoying thing with current typeahead is the fact that the programmer has to handle initialization of data in the control by using the method setQuery and.. in case of prefetched data, this has to be one after the control is initialized.
Another thing related to this is that when remote data has been selected, it will trigger extra remote lookup for the newly selected text.
All these problems are solved by changing when the internal suggestion search of the control is triggered. Now it is triggered when the control receives focus as well as when the user types in text. Suggestion search is also triggered when prefetched data has initialized, if the control is focused, so programmers no longer have to implement capture of the typeahead:initialized event.
Another benefit of this change is that data initialization will not trigger remote searches firing of on page load.
Let’s say you have 10 typeahead controls hooked up with remote data on your page and all of them include preset values. In the previous version this would have resulted in 10 remote lookups firing of when the page is loaded... well not anymore.
Busy indication
New event busyUpdate has been implemented. It will fire of when the busy state of the control is changed. This includes both initialization of local/prefetched data and when suggestion search is running. This enables programmers to easily hook up loaders or busy-indicators to the control. The knockout binding handler also supports this by allowing data binding to the isBusy option.

JQuery Examples and Plunks ready
https://github.com/Svakinn/typeahead.js/blob/typeaheadSimple/Examples.md

@jharding
Copy link
Contributor

jharding commented Feb 5, 2014

@Svakinn once again, I can't thank you enough for the work you did. I really appreciate it. Now that v0.10.0 has been released, I wanted to circle back and touch upon the status of all of the issues mentioned in this PR:

Critical bugfix - IE11 problems caused by failed browser detection.

Fixed!

Bugfix - Mouse-click on dropdown selection caused focus and blur events to occur on the input control.

Fixed!

Critical Bugfix - Local data suggestion search broke on suggestions that had space in the display name.

How this works is now configurable based on the tokenizers provided.

New urgent feature - Allowing for custom, on-demand data retrieval without direct Ajax call.

I believe this should be resolved. You can now specify your own source so that should provide enough flexibility to do just about anything.

New urgent feature - Not to require display names to be unique

Fixed!

New urgent feature - Getting control over the internal cache for remote data

Much requested basic feature - Get some handle on when customer exits input box without picking name from the suggestion list.

Tracking at #521 and #562.

Requested basic feature Get suggestions before typing starts.

Tracking at #550. Also there are 2 pending pull requests: #372 and #390. Both of those pull requests were against v0.9.3 so they need to be updated if one of them is to be accepted.

New feature - Simplified initialization - suggestion search triggering (on demand)

Seems like this covers a few issues:

  1. selecting a suggestion results in an extra request to the remote endpoint.
  2. the initialization point of the suggestion engine.
  3. typeaheads do lookups after they're initialized. (was this really the previous behavior?)

All 3 of those issues should be resolved. For 1, that bug has been fixed. For 2, the caller now controls when the suggestion engine gets initialized. For 3, I cannot reproduce that behavior in v0.10.0, so I assume it's fixed.

New feature - Busy indication

Tracking at #166.

A must for myself. - Nicely working Knockout Binding Handler, simplifying the set-up of the control and data-binding to the typed text, the selected datum and the suggestion data.

Not something that should be added to typeahead.js IMO.

@jharding jharding closed this Feb 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants