question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

typeahead: constant dropdown items re-rendering

See original GitHub issue

On the demo site the whole suggestion list for typeahead gets re-rendered on any event. For example on arrow up, arrow down, hovering mouse over items, etc.

screen shot 2016-08-01 at 15 26 47

I would expect only the active css class to change

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maxokorokovcommented, Aug 4, 2016

@Basewq I just tested it and this removes both excessive rendering and (click) issues inside the template. Indeed, looks like the issue was doing new ResultTplCtx() each time. Simple enough fix for me, thanks! Opened a pull request.

0reactions
Basewqcommented, Aug 4, 2016

I think the issue can be solved by inlining the ngOutletContext object in typeahead-window, ie. <template [ngTemplateOutlet]="resultTemplate || rt" [ngOutletContext]="_prepareTplCtx(result)"></template> to <template [ngTemplateOutlet]="resultTemplate || rt" [ngOutletContext]="{result:result, term: term, formatter: formatter}"></template>

Excuse the messy plunker: https://plnkr.co/edit/yHFIDu7xKhISlGzoDY39?p=preview I tested changing the line in file src/typeaheadwin.ts and it seems to stop the rerendering on mouse events.

Can someone test this is the case?

If this is indeed the fix, can we try reverting back the mousedown event to click (#527), as most people expect the selection to occur on mouse up, as I think the mouse event issue was caused by some sort of race condition with the re-rendered template.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactJS | antd | Facing issue in sustaining selection on re ...
I am trying to dispatch an action onSelect of a component to populate another dropdown. I have used onSelect event-handler to achieve that ......
Read more >
How to rerender dropdown after the entire select's HTML was ...
Hi, I have some <select> elements on my page, which are decorated with the kendoDropDownList widget. The problem is, that their content can ......
Read more >
How to Save State to LocalStorage & Persist on Refresh with ...
Fortunately we have some options for we can layer storage on top of React State and keep those values around for as long...
Read more >
3 Ways to Render Large Lists in Angular - Bits and Pieces
We're rendering 500 items at once, and the rendering happens outside of the container boundaries. Some issues may arise with the container ...
Read more >
React useReducer Hook ultimate guide - LogRocket Blog
While Redux, Recoil, and MobX are usually the best options for managing global state in large React applications, more often than necessary, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found