The slds page: https://www.lightningdesignsystem.com/components/lookups/#flavor-single-active has the examples of doing a perfect lookup input.
The sample code of typeahead is this:
<div class="slds-form-element slds-lookup slds-is-open" data-select="single">
<label class="slds-form-element__label" for="lookup-366">Account Name</label>
<div class="slds-form-element__control">
<div class="slds-input-has-icon slds-input-has-icon--right">
<svg aria-hidden="true" class="slds-input__icon">
<use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#search"></use>
</svg>
<input id="lookup-366" class="slds-lookup__search-input slds-input" type="search" placeholder="Search Accounts" aria-owns="lookup-366" role="combobox" aria-activedescendent="" aria-expanded="true" aria-autocomplete="list" value="salesforce" />
</div>
</div>
<div class="slds-lookup__menu" id="lookup-366">
<ul class="slds-lookup__list" role="listbox">
<li role="presentation">
<span class="slds-lookup__item-action slds-lookup__item-action--label" id="lookup-option-368" role="option">
<svg aria-hidden="true" class="slds-icon slds-icon--x-small slds-icon-text-default">
<use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#search"></use>
</svg>
<span class="slds-truncate" title="{ props.text || 'New Account' }">"salesforce" in accounts</span>
</span>
</li>
<li role="presentation">
<span class="slds-lookup__item-action slds-media slds-media--center" id="lookup-option-369" role="option">
<svg aria-hidden="true" class="slds-icon slds-icon-standard-account slds-icon--small slds-media__figure">
<use xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#account"></use>
</svg>
<div class="slds-media__body">
<div class="slds-lookup__result-text">
<mark>Salesforce</mark>.com, Inc.</div>
<span class="slds-lookup__result-meta slds-text-body--small">Account • San Francisco</span>
</div>
</span>
</li>
<li role="presentation">
<span class="slds-lookup__item-action slds-lookup__item-action--label" id="lookup-option-370" role="option">
<svg aria-hidden="true" class="slds-icon slds-icon--x-small slds-icon-text-default">
<use xlink:href="/assets/icons/utility-sprite/svg/symbols.svg#add"></use>
</svg>
<span class="slds-truncate" title="{ props.text || 'New Account' }">New Account</span>
</span>
</li>
</ul>
</div>
</div>
However, despite this long piece of code, I am still confused by several things:
- the value selected by this will be the name of the SObject record, instead of Id.
- How should I implement the New Account functionality? Should it be a page redirection or dialog? LEX is using dialog. However, I find it difficult to implement that way. And page redirection just don't seem that correct.
Any suggestions?