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
Lookup as autocomplete #2
Comments
Could you please create a gist for this? |
options definition |
https://gist.dumber.app/?gist=01ac584061194a3093bb58cec8bbe8a6 |
dumber.app does not support
Also, your options function is incorrect - firstly, it does not filter and secondly, it ignores the second parameter which is a value. |
You can have a look at the default options function provided by the component itself for the correct implementation |
I updated the gist. I have now also included the second 'value' parameter in the function, but it is always undefined. |
The async getOptionsDefault(filter: string, value: unknown): Promise<unknown[]> {
const options = this.options as unknown[];
if (value) {
return Promise.resolve([options.find(x => this.getValue(x) === value)]);
} else {
return Promise.resolve(options.filter(x => this.getDisplay(x).toUpperCase().includes((filter || '').toUpperCase())));
}
} |
Updated the gist again. I think it should be OK now. But I still cannot use it an an autocomplete. I set some remarks in the code why I cannot use it now for an autocomplete. |
If you throw an error from the options function it will be displayed in a menu. The error is templateable as well. |
Update gist again with a Promise reject. Looks OK, but I get an error that at initial load the reject is not catched. |
simple |
btw, if no element are found it's better to return an empty list. This handled differently and a templated "not found" item is shown |
also, you need to either wrap text field and lookup with something with an |
I really wanted an autocomplete. So that only something happens if you type in something which is then autocompleted. So the 'Not Found' when just clicking the input is not what I want. |
If you change the reject when nothing is typed to a resolve with an empty list, then the reject error is not shown in the console. |
I added the hoist-to-body |
Please look at https://jqueryui.com/autocomplete/ |
I was looking at the app logs. There is indeed an error in the browser console which is fixable by a proper try/catch in the component. |
Should be fixed via d4e8ebc |
If the function returns a Promise returning |
I am trying your components as an alternative to mine.
What I made myself is an autocomplete. For example you want to select a contact.; you type in some letters; a request is going to the backend to search for a name starting with those letter; and a menu is shown where you can select the right contact.
I have tried to use the lookup for that. I have set the
options
field to a function that returns a list of contact depending on what you have typed in the input. I have a couple of problems with the current implementation.Are you planning this kind of functionality in the lookup or do you see this as a separate autocomplete control?
I could of course make it myself, but if you already planned this, I am not going to. I can help you of course if you like.
The text was updated successfully, but these errors were encountered: