Skip to content

Commit 83f3c7c

Browse files
authored
fix: InputGroup validation changes (#1260)
BREAKING CHANGE * fix: focus lost after validation changes * fix: duplicate popper in SearchInput * fix: storyshots * fix: search input validation props * fix: tests * fix: tests, refactor searchinput props
1 parent 930b158 commit 83f3c7c

File tree

19 files changed

+2611
-1727
lines changed

19 files changed

+2611
-1727
lines changed

src/ComboboxInput/ComboboxInput.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('<ComboboxInput />', () => {
5454
);
5555

5656
expect(
57-
element.find('div.fd-popover').getDOMNode().attributes['data-sample'].value
57+
element.find('div.fd-popover').first().getDOMNode().attributes['data-sample'].value
5858
).toBe('Sample');
5959
});
6060

src/ComboboxInput/__stories__/__snapshots__/ComboboxInput.stories.storyshot

Lines changed: 313 additions & 169 deletions
Large diffs are not rendered by default.

src/DatePicker/DatePicker.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ describe('<DatePicker />', () => {
535535
const element = mount(<DatePicker inputGroupProps={{ 'data-sample': 'Sample' }} />);
536536

537537
expect(
538-
element.find('InputGroup').at(1).getDOMNode().attributes['data-sample'].value
538+
element.find('.fd-input-group').getDOMNode().attributes['data-sample'].value
539539
).toBe('Sample');
540540
});
541541

src/DatePicker/__stories__/__snapshots__/DatePicker.stories.storyshot

Lines changed: 1010 additions & 626 deletions
Large diffs are not rendered by default.

src/Forms/_FormValidationOverlay.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ const FormValidationOverlay = React.forwardRef((
3232
};
3333

3434
const _handleFocus = () => {
35-
if (validationState?.text?.length > 0) {
36-
setShowValidationMessage(true);
37-
}
35+
setShowValidationMessage(true);
3836
};
3937

4038
const popoverClasses = classnames(`${cssNamespace}-popover`, className);
@@ -62,7 +60,7 @@ const FormValidationOverlay = React.forwardRef((
6260
popperProps={popperProps}
6361
referenceClassName={referenceClasses}
6462
referenceComponent={referenceComponent}
65-
show={showValidationMessage}
63+
show={showValidationMessage && validationState?.text?.length > 0}
6664
usePortal>
6765
{bodyContent}
6866
</Popper>

src/Forms/_FormValidationOverlay.test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe('<FormValidationOverlay />', () => {
6363
await act(async() => {
6464
setup({
6565
popperClassName: 'wonderful-styles',
66-
show: true
66+
show: true,
67+
validationState: { state: 'error', text: 'test message' }
6768
});
6869
});
6970
const popoverNode = getPopover();
@@ -77,8 +78,8 @@ describe('<FormValidationOverlay />', () => {
7778
await act(async() => {
7879
element = setup({
7980
formMessageProps: { 'data-sample': 'Sample' },
80-
validationState: { state: 'error', message: 'test message' },
81-
show: true
81+
show: true,
82+
validationState: { state: 'error', text: 'test message' }
8283
});
8384
});
8485

@@ -92,7 +93,7 @@ describe('<FormValidationOverlay />', () => {
9293
test('Should show popover when trigger receives focus & hide popover when trigger loses focus (i.e. blurs)', async() => {
9394
let element = setup({
9495
formMessageProps: { 'data-sample': 'Sample' },
95-
validationState: { state: 'error', message: 'test message' }
96+
validationState: { state: 'error', text: 'test message' }
9697
});
9798
await act(async() => {
9899
element.find('input').simulate('focus');

src/Forms/__stories__/__snapshots__/FormGroup.stories.storyshot

Lines changed: 66 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,42 @@ exports[`Storyshots Component API/Forms/FormGroup No Styles 1`] = `
1616
className="xxx-form-item"
1717
>
1818
<div
19-
className="xxx-input-group"
19+
className="xxx-popover"
20+
onBlur={[Function]}
21+
onFocus={[Function]}
2022
>
21-
<span
22-
className="xxx-input-group__addon xxx-input-group__addon--button"
23+
<div
24+
onFocus={[Function]}
25+
onMouseDown={[Function]}
26+
onTouchStart={[Function]}
2327
>
24-
<button
25-
className="xxx-button xxx-button--transparent xxx-input-group__button"
26-
type="button"
28+
<div
29+
className="xxx-popover__control"
2730
>
28-
<i
29-
aria-hidden={true}
30-
className="sap-icon--accept"
31-
role="img"
32-
/>
33-
</button>
34-
</span>
35-
<input
36-
className="xxx-input xxx-input-group__input"
37-
type="text"
38-
/>
31+
<div
32+
className="xxx-input-group"
33+
>
34+
<span
35+
className="xxx-input-group__addon xxx-input-group__addon--button"
36+
>
37+
<button
38+
className="xxx-button xxx-button--transparent xxx-input-group__button"
39+
type="button"
40+
>
41+
<i
42+
aria-hidden={true}
43+
className="sap-icon--accept"
44+
role="img"
45+
/>
46+
</button>
47+
</span>
48+
<input
49+
className="xxx-input xxx-input-group__input"
50+
type="text"
51+
/>
52+
</div>
53+
</div>
54+
</div>
3955
</div>
4056
</div>
4157
</div>
@@ -58,26 +74,42 @@ exports[`Storyshots Component API/Forms/FormGroup Primary 1`] = `
5874
className="fd-form-item"
5975
>
6076
<div
61-
className="fd-input-group"
77+
className="fd-popover"
78+
onBlur={[Function]}
79+
onFocus={[Function]}
6280
>
63-
<span
64-
className="fd-input-group__addon fd-input-group__addon--button"
81+
<div
82+
onFocus={[Function]}
83+
onMouseDown={[Function]}
84+
onTouchStart={[Function]}
6585
>
66-
<button
67-
className="fd-button fd-button--transparent fd-input-group__button"
68-
type="button"
86+
<div
87+
className="fd-popover__control"
6988
>
70-
<i
71-
aria-hidden={true}
72-
className="sap-icon--accept"
73-
role="img"
74-
/>
75-
</button>
76-
</span>
77-
<input
78-
className="fd-input fd-input-group__input"
79-
type="text"
80-
/>
89+
<div
90+
className="fd-input-group"
91+
>
92+
<span
93+
className="fd-input-group__addon fd-input-group__addon--button"
94+
>
95+
<button
96+
className="fd-button fd-button--transparent fd-input-group__button"
97+
type="button"
98+
>
99+
<i
100+
aria-hidden={true}
101+
className="sap-icon--accept"
102+
role="img"
103+
/>
104+
</button>
105+
</span>
106+
<input
107+
className="fd-input fd-input-group__input"
108+
type="text"
109+
/>
110+
</div>
111+
</div>
112+
</div>
81113
</div>
82114
</div>
83115
</div>

src/InputGroup/InputGroup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ class InputGroup extends Component {
6767
</div>
6868
);
6969

70-
return validationState?.state ? (
70+
return (
7171
<FormValidationOverlay
7272
{...validationOverlayProps}
7373
control={inputGroup}
7474
validationState={validationState} />
75-
) : inputGroup;
75+
);
7676
}
7777
}
7878

src/InputGroup/InputGroup.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('<InputGroup />', () => {
3030

3131
it('should have a default class of "fd-input-group"', () => {
3232
expect(
33-
element.getDOMNode().className
33+
element.find('.fd-popover__control').childAt(0).getDOMNode().className
3434
).toContain('fd-input-group');
3535
});
3636
});
@@ -42,7 +42,7 @@ describe('<InputGroup />', () => {
4242
});
4343

4444
expect(
45-
element.getDOMNode().attributes['data-sample'].value
45+
element.find('.fd-popover__control').childAt(0).getDOMNode().attributes['data-sample'].value
4646
).toBe('Sample');
4747
});
4848

0 commit comments

Comments
 (0)