Skip to content

Commit 47568b5

Browse files
committed
fix of #683
1 parent 5120961 commit 47568b5

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

src/controls/listItemPicker/ComboBoxListItemPicker.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
3131
}
3232

3333
public componentDidMount(): void {
34-
this.loadOptions();
34+
this.loadOptions(this.props);
3535
}
3636

37-
protected async loadOptions(): Promise<void> {
37+
protected async loadOptions(props: IComboBoxListItemPickerProps, isInitialLoad?: boolean): Promise<void> {
3838
const {
3939
filter,
4040
keyColumnInternalName,
@@ -44,7 +44,7 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
4444
itemLimit,
4545
defaultSelectedItems,
4646
onInitialized
47-
} = this.props;
47+
} = props;
4848
let query = filter || "";
4949
//query += filter;
5050
let keyColumnName = keyColumnInternalName || "Id";
@@ -73,17 +73,24 @@ export class ComboBoxListItemPicker extends React.Component<IComboBoxListItemPic
7373
this.setState({
7474
availableOptions: options
7575
});
76-
if(onInitialized){
76+
if(onInitialized && isInitialLoad !== false){
7777
onInitialized();
7878
}
7979
}
8080

81-
public componentDidUpdate(prevProps: IComboBoxListItemPickerProps, prevState: IComboBoxListItemPickerState): void {
82-
if (this.props.listId !== prevProps.listId) {
81+
public async componentWillReceiveProps(nextProps: IComboBoxListItemPickerProps): Promise<void> {
82+
if (nextProps.listId !== this.props.listId) {
83+
await this.loadOptions(nextProps, false);
8384
this.selectedItems = [];
8485
}
8586
}
8687

88+
/*public componentDidUpdate(prevProps: IComboBoxListItemPickerProps, prevState: IComboBoxListItemPickerState): void {
89+
if (this.props.listId !== prevProps.listId) {
90+
91+
}
92+
}*/
93+
8794
/**
8895
* Render the field
8996
*/

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { TermLabelAction, TermActionsDisplayMode } from '../../../controls/taxon
3333
import { ListItemAttachments } from '../../../ListItemAttachments';
3434
import { RichText } from '../../../RichText';
3535
import { Link } from 'office-ui-fabric-react/lib/components/Link';
36-
import { Carousel, CarouselButtonsLocation, CarouselButtonsDisplay, CarouselIndicatorShape, CarouselIndicatorsDisplay } from '../../../controls/carousel';
36+
import { Carousel, CarouselButtonsLocation, CarouselButtonsDisplay, CarouselIndicatorShape, CarouselIndicatorsDisplay } from '../../../controls/carousel';
3737
import { TimeDisplayControlType } from '../../../controls/dateTimePicker/TimeDisplayControlType';
3838
import { GridLayout } from '../../../GridLayout';
3939
import { ComboBoxListItemPicker } from '../../../controls/listItemPicker/ComboBoxListItemPicker';
@@ -309,7 +309,8 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
309309
richTextValue: null,
310310
canMovePrev: false,
311311
canMoveNext: true,
312-
currentCarouselElement: this.carouselElements[0]
312+
currentCarouselElement: this.carouselElements[0],
313+
comboBoxListItemPickerListId: '0ffa51d7-4ad1-4f04-8cfe-98209905d6da'
313314
};
314315

315316
this._onIconSizeChange = this._onIconSizeChange.bind(this);
@@ -1106,7 +1107,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
11061107

11071108
<div className="ms-font-m">ComboBoxListItemPicker:
11081109

1109-
<ComboBoxListItemPicker listId={'0ffa51d7-4ad1-4f04-8cfe-98209905d6da'}
1110+
<ComboBoxListItemPicker listId={this.state.comboBoxListItemPickerListId}
11101111
columnInternalName='Title'
11111112
keyColumnInternalName='Id'
11121113
multiSelect={true}
@@ -1116,6 +1117,10 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
11161117
webUrl={this.props.context.pageContext.web.absoluteUrl}
11171118
spHttpClient={this.props.context.spHttpClient} />
11181119

1120+
<PrimaryButton text="Change List" onClick={() => { this.setState({
1121+
comboBoxListItemPickerListId: '71210430-8436-4962-a14d-5525475abd6b'
1122+
}); }} />
1123+
11191124
</div>
11201125

11211126
<div className="ms-font-m">iframe dialog tester:
@@ -1128,7 +1133,15 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
11281133
hidden={!this.state.iFrameDialogOpened}
11291134
onDismiss={() => { this.setState({ iFrameDialogOpened: false }); }}
11301135
modalProps={{
1131-
isBlocking: true
1136+
isBlocking: true,
1137+
styles: {
1138+
root: {
1139+
backgroundColor: '#00ff00'
1140+
},
1141+
main: {
1142+
backgroundColor: '#ff0000'
1143+
}
1144+
}
11321145
}}
11331146
dialogContentProps={{
11341147
type: DialogType.close,
@@ -1324,7 +1337,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
13241337
onExpandCollapse={this.onExpandCollapseTree}
13251338
onSelect={this.onItemSelected}
13261339
defaultExpandedChildren={true}
1327-
//expandToSelected={true}
1340+
//expandToSelected={true}
13281341
// onRenderItem={this.renderCustomTreeItem}
13291342
/>
13301343

src/webparts/controlsTest/components/ControlsTest_SingleComponent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
131131
richTextValue: null,
132132
canMovePrev: false,
133133
canMoveNext: true,
134-
currentCarouselElement: this.carouselElements[0]
134+
currentCarouselElement: this.carouselElements[0],
135+
comboBoxListItemPickerListId: '0ffa51d7-4ad1-4f04-8cfe-98209905d6da'
135136
};
136137

137138
this._onIconSizeChange = this._onIconSizeChange.bind(this);

src/webparts/controlsTest/components/IControlsTestProps.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface IControlsTestState {
2828
currentCarouselElement: JSX.Element;
2929
canMovePrev: boolean;
3030
canMoveNext: boolean;
31+
comboBoxListItemPickerListId: string;
3132

3233
filePickerResult?: IFilePickerResult;
3334
}

0 commit comments

Comments
 (0)