fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

SearchBox autocomplete

Open richardzcode opened this issue 8 years ago • 27 comments

This is a question or feature request.

In docs, https://developer.microsoft.com/en-us/fabric#/components/searchbox, there is a section in best practices about Autocomplete.

As the user enters a query string, they are provided with a dropdown of autocomplete suggestions or disambiguation options.

However I am not seeing anything in example and source code about autocomplete. I suppose it is not available out-of-box? If so, can we make a feature request for it?

Thanks, Richard

richardzcode avatar Jul 23 '18 21:07 richardzcode

Any updates on this? I was also looking for a sample that does the autocomplete search, not just a textbox with the word 'Search' as placeholder!

aramkoukia avatar Jul 27 '18 21:07 aramkoukia

I take this up and work on it for a new React component AutoComplete textbox

bishwenduk029 avatar Jul 29 '18 14:07 bishwenduk029

Hi @bishwenduk029 Any news? Is it completed work?

Maksim2030 avatar Sep 08 '18 10:09 Maksim2030

@IlyeniaMaksim , so can i go ahead and create a new React Component altogether and push the same here? Any suggestions if you have on approaching the issue please do share with me, it would be of great help to me....thanks

bishwenduk029 avatar Sep 10 '18 03:09 bishwenduk029

what I was looking for was Picker: https://developer.microsoft.com/en-us/fabric#/components/pickers

So I don't need this search autocomplete

aramkoukia avatar Sep 12 '18 23:09 aramkoukia

Hi, @bishwenduk029 I was wondering if you made any progress with this. It's something that I'm looking interested in. It seems that it's a common use case where whenever you do a search there is an associated auto suggestion.

It seems like it would be a merge of the picker logic into the search box. Taking the logic that create the dropdown box from picker and all the associated actions. Perhaps also handle some level of debounce built into the component.

Thanks, Derek

darewreck54 avatar Nov 10 '18 22:11 darewreck54

Hi, @darewreck54 I will continue working on the same, I got sidetracked assuming it is no longer needed, I think I understand what you are trying to implement, I will update ASAP...

bishwenduk029 avatar Nov 12 '18 15:11 bishwenduk029

@bishwenduk029 By any chance do you have an ETA?

Thanks, Derek

darewreck54 avatar Nov 16 '18 21:11 darewreck54

Hello @darewreck54 , would Wednesday evening PST do ? By then I will be able have a draft working version.

bishwenduk029 avatar Nov 19 '18 03:11 bishwenduk029

@darewreck54 as you suggested I am taking the logic from DropDown.base.tx for creating the dropdown when user enters a text into the input box. Should the trigger logic be invoked when clicks/enters, or as the user continues to type the dropdown should show result list? I am focusing the latter. Please do let me know in case this current approach needs changes

bishwenduk029 avatar Nov 19 '18 03:11 bishwenduk029

Choosing the latter is fine. I would also include a prop parameter to specify the time for the debounce. This will give the user the flexibility to control how many request are sent out. Also a prop for the method that will be trigger to retrieve the results for the suggestion.

Are you extending the existing SearchBox logic?

darewreck54 avatar Nov 19 '18 05:11 darewreck54

Yes derek with an additional prop to to activate the drop-down view of results.

On Mon, Nov 19, 2018, 10:48 Derek <[email protected] wrote:

Choosing the latter is fine. I would also include a prop parameter to specify the time for the debounce. This will give the user the flexibility to control how many request are sent out. Also a prop for the method that will be trigger to retrieve the results for the suggestion.

Are you extending the existing SearchBox logic?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-ui-fabric-react/issues/5660#issuecomment-439774500, or mute the thread https://github.com/notifications/unsubscribe-auth/AD2b9SqxgvkZwu23lkVj8FRUQPxbc2pCks5uwj8_gaJpZM4Vbv-C .

bishwenduk029 avatar Nov 19 '18 11:11 bishwenduk029

To put more specifically, activate the autosuggestion functionality based on the props.

On Mon, Nov 19, 2018, 17:11 bishwendu kundu <[email protected] wrote:

Yes derek with an additional prop to to activate the drop-down view of results.

On Mon, Nov 19, 2018, 10:48 Derek <[email protected] wrote:

Choosing the latter is fine. I would also include a prop parameter to specify the time for the debounce. This will give the user the flexibility to control how many request are sent out. Also a prop for the method that will be trigger to retrieve the results for the suggestion.

Are you extending the existing SearchBox logic?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-ui-fabric-react/issues/5660#issuecomment-439774500, or mute the thread https://github.com/notifications/unsubscribe-auth/AD2b9SqxgvkZwu23lkVj8FRUQPxbc2pCks5uwj8_gaJpZM4Vbv-C .

bishwenduk029 avatar Nov 19 '18 11:11 bishwenduk029

@bishwenduk029 Yeah, let me know when you have a version. I'll be happy to test it out with the project i'm working on and give feedback! Thanks!

darewreck54 avatar Nov 20 '18 23:11 darewreck54

Hello @darewreck54 , while working on the SearchBox enhancement I just had an idea, if we leverage the idea of render props, then we can enhance the BasePicker component itself to accept any any kind of input target as props and render the same along with the suggestions triggered when user starts entering values into the input target.

Currently is tightly coupled with the Autofill input UI. Making this input as render props and passed from client code could improve its usability

We can modify the debounce logic in picker, to give control to the client via props.

<BasePicker
    renderInputTarget={<SearchBox />}
   ...aditionalProps
>
<BasePicker>

Can you please review this logic once and let me know if this could be a viable solution?

bishwenduk029 avatar Nov 21 '18 02:11 bishwenduk029

@bishwenduk029

I tired what you suggested but that doesn’t work. It looks like the renderInputTarget has no effect. The styling gets overrided by the basepicker style. You are basically left with the basepicker look and feel.

Also the basepicker does not give you the ability to style it at all from looking at the component.

<BasePicker
            onResolveSuggestions={_onFilterChanged}
            getTextFromItem={_getTextFromItem}
            pickerSuggestionsProps={{
                suggestionsHeaderText: 'Suggested Tags',
                noResultsFoundText: 'No Color Tags Found'
            }}
            renderInputTarget={
                <SearchBox
                    ariaLabel='Search'
                    placeholder='Search'
                    underlined={true}
                    value={searchInput}
                    onChange={onSearchInputChangeHandler}
                    onSearch={onSearchClickHandler}
                />
            }
            itemLimit={2}
            inputProps={{
                onBlur: (ev: React.FocusEvent<HTMLInputElement>) => console.log('onBlur called'),
                onFocus: (ev: React.FocusEvent<HTMLInputElement>) => console.log('onFocus called'),
                'aria-label': 'Tag Picker'
            }}
        />

I think the bigger question is...what's the difference between picker and search box. Why can't they be combined? If you allow styling of this combined component, then you will have it?

darewreck54 avatar Nov 21 '18 17:11 darewreck54

perhaps a better route, is creating a component that has a Search Box and a callout/dropdown attached. Then implement debounc and all that logic.

darewreck54 avatar Nov 21 '18 23:11 darewreck54

Hello Derek sorry but I am still continuing some build errors are impeding me from raising a PR. Apologies for the inconvenience, I am working on removing the build errors should have some working version by tomorrow

On Sat, Sep 8, 2018, 16:23 IlyeniaMaksim <[email protected] wrote:

Hi @bishwenduk029 https://github.com/bishwenduk029 Any news? Is it completed work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-ui-fabric-react/issues/5660#issuecomment-419632291, or mute the thread https://github.com/notifications/unsubscribe-auth/AD2b9ahwG98knA6UYI6NtX-Yq-7YKNX-ks5uY6GagaJpZM4Vbv-C .

bishwenduk029 avatar Nov 22 '18 03:11 bishwenduk029

No worries. I actually started looking at how to possible implement as well. It seems that if you could possible take the code of a drop down and change the inner workings to use a search box. This has some advantages since the picker doesn’t have the style support that the search box has. Then move over some logic in the picker. The Dropbox uses a callout.

Someone pointed out that the big difference is the picker allows a user to pick more hen one item whereas a search only does one. The picker logic still needs to be updated to support theming.

Let me know when you have the pr out and I can take a look.

Thanks Derek

On Nov 21, 2018, at 7:51 PM, Bishwendu Kundu <[email protected]mailto:[email protected]> wrote:

Hello Derek sorry but I am still continuing some build errors are impeding me from raising a PR. Apologies for the inconvenience, I am working on removing the build errors should have some working version by tomorrow

On Sat, Sep 8, 2018, 16:23 IlyeniaMaksim <[email protected]mailto:[email protected] wrote:

Hi @bishwenduk029 https://github.com/bishwenduk029 Any news? Is it completed work?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OfficeDev/office-ui-fabric-react/issues/5660#issuecomment-419632291, or mute the thread https://github.com/notifications/unsubscribe-auth/AD2b9ahwG98knA6UYI6NtX-Yq-7YKNX-ks5uY6GagaJpZM4Vbv-C .

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/OfficeDev/office-ui-fabric-react/issues/5660#issuecomment-440905025, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APbCzq8vbL0zpDF_PuZOeL1ajUYEq_Gvks5uxh9cgaJpZM4Vbv-C.

darewreck54 avatar Nov 22 '18 04:11 darewreck54

This issue has been automatically marked as stale because it has marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thank you for your contributions to Fabric React!

msft-github-bot avatar Jan 01 '19 00:01 msft-github-bot