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

Empty Form Action Fix #765

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('Autocomplete Controller', () => {

expect(controller.urlManager.state.query).toBe(query);
expect(controller.store.state.input).toBe(query);
expect(controller.store.state.url.href).toBe('http://localhost/search.html?search_query=white');
expect(controller.store.state.url.href).toBe('/search.html?search_query=white');
});

it('serializes other form input elements (settings.serializeForm)', async () => {
Expand Down Expand Up @@ -390,7 +390,7 @@ describe('Autocomplete Controller', () => {

expect(controller.urlManager.state.query).toBe(query);
expect(controller.store.state.input).toBe(query);
expect(controller.store.state.url.href).toBe('http://localhost/search.html?view=shop&search_query=white');
expect(controller.store.state.url.href).toBe('/search.html?view=shop&search_query=white');
});

it('can invoke controller track.product.click', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export class AutocompleteController extends AbstractController {
formActionUrl = this.config.action;
} else if (form) {
form.addEventListener('submit', this.handlers.input.formSubmit as unknown as EventListener);
formActionUrl = form.action || '';
formActionUrl = form.getAttribute('action') || '';

if (this.config.settings?.serializeForm) {
bindFormParameters(form, this.handlers.input.formElementChange, function (elem: HTMLInputElement) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ describe('Autocomplete', () => {

cy.snapController('autocomplete').then(({ store }) => {
cy.wrap(store.services.urlManager.state.filter).should('exist');
cy.wrap(store.services.urlManager.href).should('contain', optionURL);
cy.wrap(optionURL).should('contain', store.services.urlManager.href);
});
});
});
Expand Down