Skip to content

Add autosuggest examples and amp-bind and action-impl changes it requires#9553

Merged
cvializ merged 6 commits intoampproject:masterfrom
cvializ:cv-autocomplete
May 31, 2017
Merged

Add autosuggest examples and amp-bind and action-impl changes it requires#9553
cvializ merged 6 commits intoampproject:masterfrom
cvializ:cv-autocomplete

Conversation

@cvializ
Copy link
Copy Markdown
Contributor

@cvializ cvializ commented May 25, 2017

Related-to #8825

@cvializ
Copy link
Copy Markdown
Contributor Author

cvializ commented May 25, 2017

Should this be renamed to autosuggest example instead? I feel like that might communicate our intent a little better, especially for an ABE sample.

applyBinding_(boundProperty, element, newValue) {
const property = boundProperty.property;
switch (property) {
case 'value':
Copy link
Copy Markdown
Contributor

@kmh287 kmh287 May 25, 2017

Choose a reason for hiding this comment

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

Bind should already support binding to the value attribute on input elements. If this code is removed, does your example break?

Copy link
Copy Markdown
Contributor Author

@cvializ cvializ May 25, 2017

Choose a reason for hiding this comment

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

It sets the attribute, but that only works the first time. Subsequent changes to the value attribute don't change the text inside the element : / Changing the value property of the element consistently updates the text.

layout="fixed-height"
height="120"
src="/form/autocomplete/query"
[src]="'/form/autocomplete/query?q=' + autocomplete"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If autocomplete isn't defined in the first AMP.setState action, the src attribute will be changed to '/form/autocomplete/query?q=null"

I recommend changing this to

 [src]="'/form/autocomplete/query' + (autocomplete ? '?q=' + autocomplete : '')

that way, null can't get into the query param and the default evaluation of the expression for [src] is equal to the initial vlaue for src.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, done.

Copy link
Copy Markdown
Contributor

@aghassemi aghassemi left a comment

Choose a reason for hiding this comment

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

LGTM, pending Will//Kevin approval for bind changes.

});
});

const autocompleteLanguages = ['ActionScript', 'AppleScript', 'Asp', 'BASIC',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

list is missing my favourite languages, will not approve PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hahaha too bad!

@@ -0,0 +1,118 @@
<!doctype html>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

plz run through validator to be sure valid then add to test-example-validation

@cvializ cvializ changed the title Add autocomplete examples and amp-bind and action-impl changes it requires Add autosuggest examples and amp-bind and action-impl changes it requires May 26, 2017
@cvializ cvializ force-pushed the cv-autocomplete branch from d417e2a to 3021270 Compare May 26, 2017 16:33
@cvializ cvializ force-pushed the cv-autocomplete branch from 3021270 to 1f621aa Compare May 31, 2017 15:45
@cvializ cvializ merged commit fb78cfb into ampproject:master May 31, 2017
@cvializ cvializ deleted the cv-autocomplete branch May 31, 2017 16:32
@kmh287
Copy link
Copy Markdown
Contributor

kmh287 commented May 31, 2017

a little late but LGTM 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants