Skip to content

Commit

Permalink
focus order changed (#2155)
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshmi2506 authored Dec 28, 2023
1 parent 24ebbaf commit 5e28f2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/js/components/tasks/retrieveMetadata/changes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Checkbox from '@salesforce/design-system-react/components/checkbox';
import Icon from '@salesforce/design-system-react/components/icon';
import Tooltip from '@salesforce/design-system-react/components/tooltip';
import classNames from 'classnames';
import React, { ChangeEvent, useState } from 'react';
import React, { ChangeEvent, RefObject, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';

import {
Expand Down Expand Up @@ -208,6 +208,14 @@ const ChangesForm = ({
updateChecked(ignoredChanges, checked);
};

interface CheckboxRefType {
input?: HTMLElement | null;
}
const checkboxRef: RefObject<CheckboxRefType> = React.createRef();
useEffect(() => {
checkboxRef.current?.input?.focus();
}, [checkboxRef]);

return (
<form
className="slds-form slds-p-around_large has-checkboxes"
Expand Down Expand Up @@ -239,6 +247,7 @@ const ChangesForm = ({
indeterminate={Boolean(!allChangesChecked && !noChangesChecked)}
errorText={errors.changes}
onChange={handleSelectAllChange}
ref={checkboxRef}
/>
<span className="slds-text-body_regular slds-p-top_xxx-small">
({totalChanges})
Expand Down
3 changes: 2 additions & 1 deletion test/js/components/tasks/retrieveMetadata/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('<RetrieveMetadataModal/>', () => {
fireEvent.click(getByText('Save & Next'));

const selectAll = getByLabelText('All Changes');
expect(selectAll).toHaveFocus();
fireEvent.click(selectAll);
// Click forward to the commit-message modal:
fireEvent.click(getByText('Save & Next'));
Expand All @@ -124,7 +125,7 @@ describe('<RetrieveMetadataModal/>', () => {
fireEvent.change(commitInput, { target: { value: 'My Commit' } });
fireEvent.click(submit);

expect.assertions(2);
expect.assertions(3);
await findByText('Retrieving Selected Changes…');

expect(createObject).toHaveBeenCalledTimes(1);
Expand Down

0 comments on commit 5e28f2c

Please sign in to comment.