Skip to content

Commit dcd112a

Browse files
authored
Merge branch 'master' into expose-celleditexit-evt
2 parents a1efcd5 + 8df3307 commit dcd112a

File tree

13 files changed

+199
-49
lines changed

13 files changed

+199
-49
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ All notable changes for each version of this project will be documented in this
2525
- **Breaking Change** - Deprecated the `label` property.
2626
- `igxGridActions`
2727
- Added `asMenuItems` Input for grid actions - `igx-grid-editing-actions`, `igx-grid-pinning-actions`. When set to true will render the related action buttons as separate menu items with button and label.
28+
- `IgxExpansionPanel`
29+
- `IExpansionPanelEventArgs.panel` - Deprecated. Usе `owner` property to get a reference to the panel.
2830

2931
### New Features
3032
- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
@@ -63,6 +65,9 @@ All notable changes for each version of this project will be documented in this
6365
- The component now utilizes the `IgxOverlayService` to position itself in the DOM.
6466
- An additional input property `outlet` has been added to allow users to specify custom Overlay Outlets using the `IgxOverlayOutletDirective`;
6567
- The `position` property now accepts values of type `IgxToastPosition` that work with strict templates.
68+
- `IgxExpansionPanelHeader`
69+
- `onInteraction` is now cancelable
70+
- Added `iconRef` property. This can be used to get a reference to the displayed expand/collapsed indicator. Returns `null` if `iconPosition` is set to `NONE`.
6671

6772
## 10.1.0
6873

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { DisplayDensity } from '../core/density';
1919
import { AbsoluteScrollStrategy, ConnectedPositioningStrategy } from '../services/public_api';
2020
import { IgxSelectionAPIService } from '../core/selection';
2121
import { IgxIconService } from '../icon/public_api';
22-
import { CancelableEventArgs } from '../core/utils';
2322

2423
const CSS_CLASS_COMBO = 'igx-combo';
2524
const CSS_CLASS_COMBO_DROPDOWN = 'igx-combo__drop-down';
@@ -602,6 +601,38 @@ describe('igxCombo', () => {
602601
expect(combo.onSearchInput.emit).toHaveBeenCalledTimes(1);
603602
expect(matchSpy).toHaveBeenCalledTimes(1);
604603
});
604+
it('should not open on click if combo is disabled', () => {
605+
combo = new IgxComboComponent(elementRef, mockCdr, mockSelection as any, mockComboService,
606+
mockIconService, null, null, mockInjector);
607+
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['open', 'close', 'toggle']);
608+
const spyObj = jasmine.createSpyObj('event', ['stopPropagation', 'preventDefault']);
609+
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
610+
combo.ngOnInit();
611+
combo.dropdown = dropdown;
612+
dropdown.collapsed = true;
613+
614+
combo.disabled = true;
615+
combo.onInputClick(spyObj);
616+
expect(combo.dropdown.collapsed).toBeTruthy();
617+
});
618+
it('should not clear value when combo is disabled', () => {
619+
const selectionService = new IgxSelectionAPIService();
620+
combo = new IgxComboComponent(elementRef, mockCdr, selectionService, mockComboService,
621+
mockIconService, null, null, mockInjector);
622+
const dropdown = jasmine.createSpyObj('IgxComboDropDownComponent', ['selectItem']);
623+
const spyObj = jasmine.createSpyObj('event', ['stopPropagation']);
624+
spyOn(mockIconService, 'addSvgIconFromText').and.returnValue(null);
625+
combo.ngOnInit();
626+
combo.data = data;
627+
combo.dropdown = dropdown;
628+
combo.disabled = true;
629+
spyOnProperty(combo, 'totalItemCount').and.returnValue(combo.data.length);
630+
631+
const item = combo.data.slice(0, 1);
632+
combo.selectItems(item, true);
633+
combo.handleClearItems(spyObj);
634+
expect(combo.value).toEqual(item[0]);
635+
});
605636
});
606637
describe('Initialization and rendering tests: ', () => {
607638
configureTestSuite();
@@ -2541,13 +2572,6 @@ describe('igxCombo', () => {
25412572
expect(combo.valid).toEqual(IgxComboState.INITIAL);
25422573
expect(combo.comboInput.valid).toEqual(IgxInputState.INITIAL);
25432574
});
2544-
it('should not open on click if combo is disabled', () => {
2545-
combo.disabled = true;
2546-
fixture.detectChanges();
2547-
UIInteractions.simulateClickEvent(combo.comboInput.nativeElement);
2548-
fixture.detectChanges();
2549-
expect(combo.dropdown.collapsed).toBeTruthy();
2550-
});
25512575
it('should be possible to be enabled/disabled when used as a form control', () => {
25522576
const form = fixture.componentInstance.reactiveForm;
25532577
const comboFormReference = form.controls.townCombo;

projects/igniteui-angular/src/lib/combo/combo.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,9 @@ export class IgxComboComponent extends DisplayDensityBase implements IgxComboBas
13241324
* @hidden @internal
13251325
*/
13261326
public handleClearItems(event: Event): void {
1327+
if (this.disabled) {
1328+
return;
1329+
}
13271330
this.deselectAllItems(true, event);
13281331
if (this.collapsed) {
13291332
this.getEditElement().focus();

projects/igniteui-angular/src/lib/core/styles/components/action-strip/_action-strip-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
55
/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a>
66
////
7-
///
7+
88
/// If only background color is specified, text/icon color will be assigned automatically to a contrasting color.
99
/// @param {Map} $palette [$default-palette] - The palette used as basis for styling the component.
1010
/// @param {Map} $schema [$light-schema] - The schema used as basis for styling the component.

projects/igniteui-angular/src/lib/expansion-panel/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ The following outputs are available in the **igx-expansion-panel** component:
5656

5757
| Name | Cancelable | Description | Parameters
5858
| :--- | :--- | :--- | :--- |
59-
| `onCollapsed` | `false` | Emitted when the panel is collapsed | `{ event: Event, panel: IgxExpansionPanelComponent }` |
60-
| `onExpanded` | `false` | Emitted when the panel is expanded | `{ event: Event, panel: IgxExpansionPanelComponent }` |
59+
| `onCollapsed` | `false` | Emitted when the panel is collapsed | `IExpansionPanelEventArgs` |
60+
| `onExpanded` | `false` | Emitted when the panel is expanded | `IExpansionPanelEventArgs` |
6161

6262

6363
### Methods
@@ -81,14 +81,15 @@ The following inputs are available in the **igx-expansion-panel-header** compone
8181
| `role` | `string` | The `role` attribute of the header |
8282
| `iconPosition` | `string` | The position of the expand/collapse icon of the header |
8383
| `disabled` | `boolean` | Gets/sets whether the panel header is disabled (blocking user interaction) or not |
84+
| `iconRef` | `ElementRef` | Gets the reference to the element being used as expand/collapse indicator. If `iconPosition` is `NONE` - return `null` |
8485

8586

8687
### Outputs
8788
The following outputs are available in the **igx-expansion-panel-header** component:
8889

8990
| Name | Cancelable | Description | Parameters
9091
| :--- | :--- | :--- | :--- |
91-
| `onInteraction` | `false` | Emitted when a user interacts with the header host | `{ event: Event, panel: IgxExpansionPanelComponent }` |
92+
| `onInteraction` | `true` | Emitted when a user interacts with the header host | `IExpansionPanelCancelableEventArgs` |
9293

9394
## IgxExpansionPanelBodyComponent
9495
### Inputs

projects/igniteui-angular/src/lib/expansion-panel/expansion-panel-header.component.ts

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import {
99
EventEmitter,
1010
Output,
1111
ContentChild,
12-
Inject
12+
Inject,
13+
ViewChild
1314
} from '@angular/core';
1415
import { IgxExpansionPanelIconDirective } from './expansion-panel.directives';
15-
import { IExpansionPanelEventArgs, IGX_EXPANSION_PANEL_COMPONENT, IgxExpansionPanelBase } from './expansion-panel.common';
16+
import { IGX_EXPANSION_PANEL_COMPONENT, IgxExpansionPanelBase, IExpansionPanelCancelableEventArgs } from './expansion-panel.common';
1617
import { mkenum } from '../core/utils';
18+
import { IgxIconComponent } from '../icon/public_api';
1719

1820
/**
1921
* @hidden
@@ -42,6 +44,23 @@ export class IgxExpansionPanelHeaderComponent {
4244
*/
4345
public id = '';
4446

47+
/** @hidden @internal */
48+
@ContentChild(IgxExpansionPanelIconDirective, { read: ElementRef })
49+
private customIconRef: ElementRef;
50+
51+
/** @hidden @internal */
52+
@ViewChild(IgxIconComponent, { read: ElementRef })
53+
public defaultIconRef: ElementRef;
54+
55+
/**
56+
* Returns a reference to the `igx-expansion-panel-icon` element;
57+
* If `iconPosition` is `NONE` - return null;
58+
*/
59+
public get iconRef(): ElementRef {
60+
const renderedTemplate = this.customIconRef ?? this.defaultIconRef;
61+
return this.iconPosition !== ICON_POSITION.NONE ? renderedTemplate : null;
62+
}
63+
4564
/**
4665
* @hidden
4766
*/
@@ -120,7 +139,7 @@ export class IgxExpansionPanelHeaderComponent {
120139
/**
121140
* Emitted whenever a user interacts with the header host
122141
* ```typescript
123-
* handleInteraction(event: IExpansionPanelEventArgs) {
142+
* handleInteraction(event: IExpansionPanelCancelableEventArgs) {
124143
* ...
125144
* }
126145
* ```
@@ -131,7 +150,7 @@ export class IgxExpansionPanelHeaderComponent {
131150
* ```
132151
*/
133152
@Output()
134-
public onInteraction = new EventEmitter<IExpansionPanelEventArgs>();
153+
public onInteraction = new EventEmitter<IExpansionPanelCancelableEventArgs >();
135154

136155
/**
137156
* @hidden
@@ -185,7 +204,11 @@ export class IgxExpansionPanelHeaderComponent {
185204
evt.stopPropagation();
186205
return;
187206
}
188-
this.onInteraction.emit({ event: evt, panel: this.panel });
207+
const eventArgs: IExpansionPanelCancelableEventArgs = { event: evt, panel: this.panel, owner: this.panel, cancel: false };
208+
this.onInteraction.emit(eventArgs);
209+
if (eventArgs.cancel === true) {
210+
return;
211+
}
189212
this.panel.toggle(evt);
190213
evt.preventDefault();
191214
}
@@ -194,17 +217,25 @@ export class IgxExpansionPanelHeaderComponent {
194217
@HostListener('keydown.Alt.ArrowDown', ['$event'])
195218
public openPanel(event: KeyboardEvent) {
196219
if (event.altKey) {
220+
const eventArgs: IExpansionPanelCancelableEventArgs = { event, panel: this.panel, owner: this.panel, cancel: false };
221+
this.onInteraction.emit(eventArgs);
222+
if (eventArgs.cancel === true) {
223+
return;
224+
}
197225
this.panel.expand(event);
198-
this.onInteraction.emit({ event: event, panel: this.panel });
199226
}
200227
}
201228

202229
/** @hidden @internal */
203230
@HostListener('keydown.Alt.ArrowUp', ['$event'])
204231
public closePanel(event: KeyboardEvent) {
205232
if (event.altKey) {
233+
const eventArgs: IExpansionPanelCancelableEventArgs = { event, panel: this.panel, owner: this.panel, cancel: false };
234+
this.onInteraction.emit(eventArgs);
235+
if (eventArgs.cancel === true) {
236+
return;
237+
}
206238
this.panel.collapse(event);
207-
this.onInteraction.emit({ event: event, panel: this.panel });
208239
}
209240
}
210241

projects/igniteui-angular/src/lib/expansion-panel/expansion-panel.common.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { EventEmitter, InjectionToken } from '@angular/core';
22
import { AnimationReferenceMetadata } from '@angular/animations';
3-
import { IBaseEventArgs } from '../core/utils';
3+
import { CancelableEventArgs, IBaseEventArgs } from '../core/utils';
44

55
export interface IgxExpansionPanelBase {
66
id: string;
@@ -21,5 +21,11 @@ export const IGX_EXPANSION_PANEL_COMPONENT = new InjectionToken<IgxExpansionPane
2121

2222
export interface IExpansionPanelEventArgs extends IBaseEventArgs {
2323
event: Event;
24-
panel: IgxExpansionPanelBase;
24+
/**
25+
* @deprecated
26+
* To get a reference to the panel, use `owner` instead.
27+
*/
28+
panel?: IgxExpansionPanelBase;
2529
}
30+
31+
export interface IExpansionPanelCancelableEventArgs extends IExpansionPanelEventArgs, CancelableEventArgs {}

projects/igniteui-angular/src/lib/expansion-panel/expansion-panel.component.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ export class IgxExpansionPanelComponent implements IgxExpansionPanelBase, AfterC
119119
/**
120120
* Emitted when the expansion panel finishes collapsing
121121
* ```typescript
122-
* handleCollapsed(event: {
123-
* panel: IgxExpansionPanelComponent,
124-
* event: Event
125-
* })
122+
* handleCollapsed(event: IExpansionPanelEventArgs)
126123
* ```
127124
* ```html
128125
* <igx-expansion-panel (onCollapsed)="handleCollapsed($event)">
@@ -136,10 +133,7 @@ export class IgxExpansionPanelComponent implements IgxExpansionPanelBase, AfterC
136133
/**
137134
* Emitted when the expansion panel finishes expanding
138135
* ```typescript
139-
* handleExpanded(event: {
140-
* panel: IgxExpansionPanelComponent,
141-
* event: Event
142-
* })
136+
* handleExpanded(event: IExpansionPanelEventArgs)
143137
* ```
144138
* ```html
145139
* <igx-expansion-panel (onExpanded)="handleExpanded($event)">
@@ -229,7 +223,7 @@ export class IgxExpansionPanelComponent implements IgxExpansionPanelBase, AfterC
229223
}
230224
this.playCloseAnimation(
231225
() => {
232-
this.onCollapsed.emit({ event: evt, panel: this });
226+
this.onCollapsed.emit({ event: evt, panel: this, owner: this });
233227
this.collapsed = true;
234228
}
235229
);
@@ -253,7 +247,7 @@ export class IgxExpansionPanelComponent implements IgxExpansionPanelBase, AfterC
253247
this.cdr.detectChanges();
254248
this.playOpenAnimation(
255249
() => {
256-
this.onExpanded.emit({ event: evt, panel: this });
250+
this.onExpanded.emit({ event: evt, panel: this, owner: this });
257251
}
258252
);
259253
}

projects/igniteui-angular/src/lib/expansion-panel/expansion-panel.directives.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Directive, HostBinding } from '@angular/core';
22

33
/**
4-
* @hidden
4+
* @hidden @internal
55
*/
66
@Directive({
77
// tslint:disable-next-line:directive-selector
@@ -13,7 +13,7 @@ export class IgxExpansionPanelTitleDirective {
1313
}
1414

1515
/**
16-
* @hidden
16+
* @hidden @internal
1717
*/
1818
@Directive({
1919
// tslint:disable-next-line:directive-selector
@@ -25,7 +25,7 @@ export class IgxExpansionPanelDescriptionDirective {
2525
}
2626

2727
/**
28-
* @hidden
28+
* @hidden @internal
2929
*/
3030
@Directive({
3131
// tslint:disable-next-line:directive-selector

0 commit comments

Comments
 (0)