Skip to content

Commit 6f7bb9e

Browse files
authored
Merge pull request #1044 from pineaulo/dev
Add onCancel callback for IconPicker
2 parents 591fcf0 + be6661f commit 6f7bb9e

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

docs/documentation/docs/controls/IconPicker.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The IconPicker component can be configured with the following properties:
4848
| ---- | ---- | ---- | ---- |
4949
| buttonLabel | string | no | Specifies the label of the icon picker button. |
5050
| onSave | (iconName: string) => void | yes | Handler when the icon has been selected and picker has been closed. |
51+
| onCancel | () => void | no | Handler when the panel is closed. |
5152
| onChange | (iconName: string) => void | no | Handler when the icon selection has been changed. |
5253
| disabled | boolean | no | Specifies if the picker button is disabled |
5354
| buttonClassName | boolean | no | If provided, additional class name will be added to the picker button |

src/controls/iconPicker/IIconPickerProps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ export interface IIconPickerProps {
33
* call-back function when icon selection has been confirmed
44
*/
55
onSave(iconName: string): void;
6+
/**
7+
* call-back function when cancel is clicked
8+
*/
9+
onCancel?(): void;
610
/**
711
* call-back function when icon has changed
812
*/

src/controls/iconPicker/IconPicker.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export class IconPicker extends React.Component<IIconPickerProps, IIconPickerSta
107107
}
108108

109109
private closePanel = (): void => {
110+
if (this.props.onCancel) {
111+
this.props.onCancel();
112+
}
110113
this.setState({
111114
currentIcon: this.props.currentIcon,
112115
isPanelOpen: false

src/webparts/controlsTest/components/ControlsTest.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,7 @@ export default class ControlsTest extends React.Component<IControlsTestProps, IC
16831683

16841684
<IconPicker buttonLabel={'Icon'}
16851685
onChange={(iconName: string) => { console.log(iconName); }}
1686+
onCancel={() => { console.log("Panel closed"); }}
16861687
onSave={(iconName: string) => { console.log(iconName); }} />
16871688

16881689
<div>

0 commit comments

Comments
 (0)