Skip to content

Commit 49afc2b

Browse files
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # package.json
2 parents f064680 + 27b6e57 commit 49afc2b

File tree

5 files changed

+247
-158
lines changed

5 files changed

+247
-158
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-lightning-design-system",
3-
"version": "4.3.3",
3+
"version": "4.4.2",
44
"description": "Salesforce Lightning Design System components built with React",
55
"main": "lib/scripts/index.js",
66
"module": "module/scripts/index.js",
@@ -112,7 +112,7 @@
112112
"react-docgen-typescript-loader": "^3.1.0",
113113
"react-dom": "^16.8.2",
114114
"react-test-renderer": "^16.8.2",
115-
"reg-keygen-git-hash-plugin": "^0.8.5",
115+
"reg-keygen-git-hash-plugin": "^0.10.16",
116116
"reg-notify-github-plugin": "^0.8.5",
117117
"reg-publish-s3-plugin": "^0.8.5",
118118
"reg-suit": "^0.8.6",

src/scripts/DateInput.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ class DateInputInner extends Component<
200200
}
201201

202202
onInputBlur(e: FocusEvent<HTMLInputElement | HTMLButtonElement>) {
203-
this.setValueFromInput(e.target.value);
203+
if (e.target.tagName.toLowerCase() === 'input') {
204+
this.setValueFromInput(e.target.value);
205+
}
204206
setTimeout(() => {
205207
if (!this.isFocusedInComponent()) {
206208
if (this.props.onBlur) {
@@ -358,7 +360,7 @@ class DateInputInner extends Component<
358360
? this.state.inputValue
359361
: dateValue != null && mvalue.isValid()
360362
? mvalue.format(this.getInputValueFormat())
361-
: undefined;
363+
: '';
362364
const isOpened = typeof opened !== 'undefined' ? opened : this.state.opened;
363365
const formElemProps = { id, totalCols, cols, label, required, error };
364366
return (

src/scripts/DropdownButton.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export type Key = string | number;
1919
export type DropdownButtonProps<EventKey extends Key> = {
2020
className?: string;
2121
label?: React.ReactNode;
22+
opened?: boolean;
23+
defaultOpened?: boolean;
2224
menuAlign?: DropdownMenuAlign;
2325
menuSize?: DropdownMenuSize;
2426
menuHeader?: string;
@@ -55,7 +57,11 @@ class DropdownButtonInner<EventKey extends Key> extends Component<
5557

5658
constructor(props: Readonly<DropdownButtonInnerProps<EventKey>>) {
5759
super(props);
58-
this.state = { opened: false };
60+
const opened =
61+
typeof this.props.opened === 'undefined'
62+
? this.props.defaultOpened || false
63+
: this.props.opened;
64+
this.state = { opened };
5965
registerStyle('no-hover-popup', [
6066
[
6167
'.slds-dropdown-trigger:hover .slds-dropdown_menu.react-slds-no-hover-popup',
@@ -80,11 +86,15 @@ class DropdownButtonInner<EventKey extends Key> extends Component<
8086
};
8187

8288
onKeyDown = (e: KeyboardEvent<HTMLButtonElement>) => {
89+
const opened =
90+
typeof this.props.opened === 'undefined'
91+
? this.state.opened
92+
: this.props.opened;
8393
if (e.keyCode === 40) {
8494
// down
8595
e.preventDefault();
8696
e.stopPropagation();
87-
if (!this.state.opened) {
97+
if (!opened) {
8898
this.setState({ opened: true });
8999
if (this.props.onClick) {
90100
this.props.onClick(e);
@@ -205,9 +215,13 @@ class DropdownButtonInner<EventKey extends Key> extends Component<
205215
...props
206216
} = this.props;
207217
let { icon } = this.props;
218+
const opened =
219+
typeof this.props.opened === 'undefined'
220+
? this.state.opened
221+
: this.props.opened;
208222
const dropdownClassNames = classnames(className, 'slds-dropdown-trigger', {
209223
'slds-button-space-left': !props.grouped,
210-
'react-slds-dropdown-opened': this.state.opened,
224+
'react-slds-dropdown-opened': opened,
211225
});
212226
let iconMore = null;
213227
if (!label && !icon) {
@@ -242,7 +256,7 @@ class DropdownButtonInner<EventKey extends Key> extends Component<
242256
ref={(node) => (this.node = node)}
243257
>
244258
{this.renderButton({ type, label, icon, iconMore, ...props })}
245-
{hoverPopup || this.state.opened ? dropdown : undefined}
259+
{hoverPopup || opened ? dropdown : undefined}
246260
</div>
247261
);
248262
}

test/storyshots/__snapshots__/storyshots.test.js.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,7 @@ exports[`Storyshots DateInput Controlled with knobs 1`] = `
17911791
onBlur={[Function]}
17921792
onChange={[Function]}
17931793
onKeyDown={[Function]}
1794+
value=""
17941795
/>
17951796
<span
17961797
className="react-slds-button-focus-wrapper"
@@ -13690,6 +13691,7 @@ exports[`Storyshots Form Compound Form 1`] = `
1369013691
onChange={[Function]}
1369113692
onKeyDown={[Function]}
1369213693
placeholder="YYYY/MM/DD"
13694+
value=""
1369313695
/>
1369413696
<span
1369513697
className="react-slds-button-focus-wrapper"
@@ -14218,6 +14220,7 @@ exports[`Storyshots Form Horizontal Form 1`] = `
1421814220
onBlur={[Function]}
1421914221
onChange={[Function]}
1422014222
onKeyDown={[Function]}
14223+
value=""
1422114224
/>
1422214225
<span
1422314226
className="react-slds-button-focus-wrapper"
@@ -14671,6 +14674,7 @@ exports[`Storyshots Form Stacked Form 1`] = `
1467114674
onBlur={[Function]}
1467214675
onChange={[Function]}
1467314676
onKeyDown={[Function]}
14677+
value=""
1467414678
/>
1467514679
<span
1467614680
className="react-slds-button-focus-wrapper"
@@ -46280,6 +46284,7 @@ exports[`Storyshots Modal Form elements 1`] = `
4628046284
onBlur={[Function]}
4628146285
onChange={[Function]}
4628246286
onKeyDown={[Function]}
46287+
value=""
4628346288
/>
4628446289
<span
4628546290
className="react-slds-button-focus-wrapper"
@@ -46336,6 +46341,7 @@ exports[`Storyshots Modal Form elements 1`] = `
4633646341
onBlur={[Function]}
4633746342
onChange={[Function]}
4633846343
onKeyDown={[Function]}
46344+
value=""
4633946345
/>
4634046346
<span
4634146347
className="react-slds-button-focus-wrapper"
@@ -46398,6 +46404,7 @@ exports[`Storyshots Modal Form elements 1`] = `
4639846404
onBlur={[Function]}
4639946405
onChange={[Function]}
4640046406
onKeyDown={[Function]}
46407+
value=""
4640146408
/>
4640246409
<span
4640346410
className="react-slds-button-focus-wrapper"

0 commit comments

Comments
 (0)