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

Component autocomplete #971

Closed
wants to merge 3 commits into from
Closed

Conversation

gcmznt
Copy link
Contributor

@gcmznt gcmznt commented Jun 5, 2018

This is the first implementation of the autocomplete text field

@carloslancha
Copy link
Contributor

Just started reviewing :)

:octocat: Sent from GH.

Copy link
Contributor

@carloslancha carloslancha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @gcmznt !

This is such a difficult component, let's go step by step to make it awesome! 😄

First of all, don't know if you already saw this but here is the docs for Lexicon Autocomplete: https://docs.google.com/document/d/15r6t5Maiavg7ggxE8ulTATTuyqGVaq75yj9p-zfsQqU/edit

One of the things we need to implement is that result should be shown alphabetically ordered.

Also I added some comments to start improving the component.

Do not hesitate to ask anything. Thanks!

label: Config.string(),
};

ClayAutocomplete.STATE = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing JSDocs in all state

};

ClayAutocomplete.STATE = {
dataSource: Config.oneOfType([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be consistent with other components such as Charts this should be named data. It should also accept an Array of Strings and a function. See https://github.com/liferay/clay/blob/master/packages/clay-charts/src/ChartBase.js#L4

Config.arrayOf(Config.shapeOf(itemShape)),
Config.string(),
]),
suggestions: Config.arrayOf(Config.shapeOf(itemShape)).value([]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All params that are meant to be used internally and not passed from the outside must be marked as internal .internal() and the name has to be preceded by _

elementClasses: Config.string(),
hasFocus: Config.bool().value(false),
id: Config.string(),
query: Config.string().value(''),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query should be always the same value of value, so I think we can get rid of this param

data-onblur="{$_handleBlur}"
data-onkeydown="{$_handleKeydown}"
>
<ul {$listAttributes}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use ClayDropdown here?

created() {
this.provider = new DataProvider(this.dataSource, {
elements: this.maxSuggestions,
paramName: 'query',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be configurable so ClayAutocomplete should receive a paramName param too.

.filter(query, data, {
// pre: '<strong>',
// post: '</strong>',
extract: el => el.label,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which object property we want to extract should be configurable.

}

function getDataFromURL(query, url, paramName = 'q', cb) {
fetch(`${url}?${paramName}=${query}`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to manage all kind of urls, for example, what if the passed url already has queryParams? You can use metal-uri https://github.com/metal/metal-plugins/tree/master/packages/metal-uri to deal with this.

@carloslancha
Copy link
Contributor

Just started reviewing :)

:octocat: Sent from GH.

@jbalsas
Copy link
Contributor

jbalsas commented Nov 21, 2018

Superseeded for now by #1292 (although we might want to take a step and extract the autocomplete feature as a standalone)

@jbalsas jbalsas closed this Nov 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants