Skip to content

Commit

Permalink
fix: (CXSPA-965) - Refocus on input after quick order with keyboard (#…
Browse files Browse the repository at this point in the history
…18313)

Co-authored-by: Piotr Bartkowiak <[email protected]>
  • Loading branch information
Pio-Bar and Piotr Bartkowiak authored Mar 18, 2024
1 parent 5aeedd7 commit affbb88
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
formControlName="product"
placeholder="{{ 'quickOrderForm.placeholder' | cxTranslate }}"
type="text"
#quickOrderInput
/>

<button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
Input,
OnDestroy,
OnInit,
ViewChild,
} from '@angular/core';
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { QuickOrderFacade } from '@spartacus/cart/quick-order/root';
Expand Down Expand Up @@ -41,6 +43,8 @@ export class QuickOrderFormComponent implements OnInit, OnDestroy {

@Input() limit: number;

@ViewChild('quickOrderInput') quickOrderInput: ElementRef;

protected subscription = new Subscription();
protected searchSubscription = new Subscription();

Expand Down Expand Up @@ -99,6 +103,7 @@ export class QuickOrderFormComponent implements OnInit, OnDestroy {
}

this.quickOrderService.addProduct(product);
this.quickOrderInput.nativeElement.focus();
}

addProduct(event: Event): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ context('B2B - Quick Order', () => {
it('should conform to tabbing order for quick order page', () => {
quickOrder.visitQuickOrderPage();
quickOrder.addProductToTheList(sampleData.b2bProduct.code);
quickOrder.verifyInputHasFocus();
quickOrder.verifyQuickOrderListQuantity(1);
quickOrder.verifyQuickOrderPageTabbingOrder();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { SampleProduct } from '../../sample-data/checkout-flow';
import { tabbingOrderConfig as config } from '../../helpers/accessibility/b2b/tabbing-order.config';
import * as sampleData from '../../sample-data/b2b-checkout';
import { SampleProduct } from '../../sample-data/checkout-flow';
import { verifyTabbingOrder as tabbingOrder } from '../accessibility/tabbing-order';
import { tabbingOrderConfig as config } from '../../helpers/accessibility/b2b/tabbing-order.config';
import { waitForPage } from '../checkout-flow';

export const ADD_TO_CART_ENDPOINT_ALIAS = 'addEntry';
Expand Down Expand Up @@ -258,3 +258,7 @@ export function verifyCartPageTabbingOrder() {
export function verifyQuickOrderPageTabbingOrder() {
tabbingOrder('cx-quick-order', config.quickOrder);
}

export function verifyInputHasFocus() {
cy.get('.quick-order-form-input input').should('be.focused');
}

0 comments on commit affbb88

Please sign in to comment.