Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: angular/components
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7.3.0
Choose a base ref
...
head repository: angular/components
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7.3.1
Choose a head ref

Commits on Feb 4, 2019

  1. build: simplify api golden target names (#14973)

    * In order to make it easier to test/update goldens, the Bazel targets are updated to the match the actual golden file paths. This is useful because developers can then use terminal autocompletion to go to the desired golden file, and just need to add the `_api` suffix. This easier than manually constructing the Bazel API target name which is not intuitive and takes up time.
    devversion authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    a1fd4bb View commit details
  2. Copy the full SHA
    bfd6dd1 View commit details
  3. chore: fix dead link in docs (#14962)

    Fixes a dead link in the a11y docs.
    
    Fixes #14955.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    39ce618 View commit details
  4. fix(examples): fix form-field custom control disabled input (#14957)

    * fixes form-field custom control example and guide so as not to attempt
      to use the `disabled` attribute on an input element that has a reactive
      form directive. see: https://github.com/angular/angular/blob/e2c98fbe11272295c3827b0e54f859d283cd32bf/packages/forms/src/directives/reactive_errors.ts#L64
    swseverance authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    ce3926d View commit details
  5. Copy the full SHA
    46517db View commit details
  6. docs: pointing out breaking change for MatSidenav and MatDrawer in 7.0 (

    #13902)
    
    * Updated Changelog
    
    Added description to Breaking changes that the template for MatSidenav and MatDrawer have changed. Was done in this 0f83c18 commit.
    
    * Update CHANGELOG.md
    Isitar authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    68bbd28 View commit details
  7. Revert "docs: pointing out breaking change for MatSidenav and MatDraw…

    …er in 7.0 (#13902)" (#14989)
    
    This reverts commit 1b2e770.
    mmalerba committed Feb 4, 2019
    Copy the full SHA
    0fcd42b View commit details
  8. fix(tree,scrolling): don't require user DataSource to extend DataSour…

    …ce (#14966)
    
    Currently the way we verify that the passed in data source is by using `instanceof` which assumes that the consumer has extended our `DataSource`. In `cdk/table` we do the verification by checking whether the object matches the interface of a `DataSource` instead.
    
    These changes add a utility method to check whether something is a data source and refactor the `tree` and `scrolling` entry points to be consistent with `table`.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    0f9926a View commit details
  9. build: fix syntax error within codeowners file (#15014)

    Since 88601fa landed, it seems that the Github codeowner's are no longer working. This is because globs with such negations are not supported within the `CODEOWNERS` file
    
    The exclusion of `.d.ts` files shouldn't be necessary anyway since the last match in the `CODEOWNERS` file takes precedence over previous matches.
    devversion authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    4d710e4 View commit details
  10. docs: fix minor typo on comment (#15002)

    extract individual colors a palette -> extract individual colors from a palette.
    ahasall authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    34025d8 View commit details
  11. Update creating-a-custom-stepper-using-the-cdk-stepper.md (#14907)

    * Update creating-a-custom-stepper-using-the-cdk-stepper.md
    
    Simplified step content projection
    
    * Update creating-a-custom-stepper-using-the-cdk-stepper.md
    
    * Updated example
    Michael Hoffmann authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    5ad5176 View commit details
  12. fix(list): selection list not picking up indirect descendants (#15003)

    Fixes `MatSelectionList` not picking up list options that aren't direct descendants.
    
    **Note:** this approach can have some side-effects if somebody decided to nest selection lists which would result in the parent picking up the options of its children. We can handle that case with some extra code, however I decided not to for now since it doesn't make sense to nest lists.
    
    Fixes #15000.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    6a07d0d View commit details
  13. fix(checkbox): not marked as touched immediately on blur with OnPush …

    …change detection (#15001)
    
    Fixes a checkbox which is blurred inside a component with `OnPush` change detection not being marked as touched.
    
    Fixes #14980.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    916c532 View commit details
  14. fix(chips): newly-added chips not being disabled when added to a disa…

    …ble list (#14976)
    
    Fixes newly-added chips not being disabled when they're added to a disabled chip list. The problem comes from the fact that the disabled state is only synced to the chips when it changes.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    c23512a View commit details
  15. fix(overlay): unnecessarily pushing overlay if it is exactly as wide …

    …as the viewport (#14975)
    
    Fixes the flexible position strategy pushing the overlay when it doesn't have to, if it's exactly as wide as the viewport.
    
    Fixes #14968.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    f4b4e61 View commit details
  16. Copy the full SHA
    ba6b405 View commit details
  17. fix(table): allow for a caption to be projected (#14965)

    Fixes consumers not being allowed to project a caption into a CDK table.
    
    Fixes #14948.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    a8a6617 View commit details
  18. fix(button): not updating DOM node name if group name changes (#14963)

    Fixes the underlying DOM node's name not being in sync with the group, if the group's name is set through the input.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    37732cb View commit details
  19. fix(slider): focus ring showing when ancestor has focus monitoring (#…

    …14960)
    
    Fixes an overly-broad selector that meant that the slider's focus ring would show if any of its ancestors has focus monitoring.
    
    Fixes #14958.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    2ec9dff View commit details
  20. fix(radio): not updating DOM node name if group name changes (#14950)

    Fixes the `name` of the underlying radio button DOM nodes not being updated, if the name of the parent group changes.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    4d5c5d5 View commit details
  21. fix(table): Clarify unknown table column error (#14947)

    Throwing error when column not found in _addStickyColumnStyles to avoid weird error of
    "Cannot read property 'sticky' of undefined".
    CaptainCow95 authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    2782273 View commit details
  22. fix(cdk-stepper): coercing selectedIndex value to a Number (#14817)

    * fix(cdk-stepper): coercing selectedIndex value to a Number
    
    * test(cdk-stepper): preselected value should be number
    s2-abdo authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    b64c08d View commit details
  23. perf(focus-monitor): avoid triggering change detection if there are n…

    …o subscribers to stream (#14964)
    
    Currently we have an `NgZone.run` call on each `focus` and `blur` event of a monitored element in order to bring its subscribers into the `NgZone`, however this means that we're also triggering change detection to any consumers that aren't subscribed to changes (e.g. `mat-button` only cares about the classes being applied). These changes move around some logic so that the `NgZone.run` is only hit if somebody has subscribed to the observable.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    011a0d0 View commit details
  24. fix(radio): unable to click to select button if text is marked (#14967)

    Fixes not being able to select a radio button by clicking on it, if part of the text of the label is marked.
    
    Fixes #14753.
    crisbeto authored and mmalerba committed Feb 4, 2019
    Copy the full SHA
    81380d2 View commit details
  25. Revert "perf(focus-monitor): avoid triggering change detection if the…

    …re are no subscribers to stream" (#15076)
    
    * Revert "fix(radio): unable to click to select button if text is marked (#14967)"
    
    This reverts commit 5846038.
    
    * Revert "perf(focus-monitor): avoid triggering change detection if there are no subscribers to stream (#14964)"
    
    This reverts commit 085bbb7.
    mmalerba committed Feb 4, 2019
    Copy the full SHA
    e6500fb View commit details
  26. Copy the full SHA
    3bf1fea View commit details
Showing with 517 additions and 233 deletions.
  1. +1 −1 .github/CODEOWNERS
  2. +22 −0 CHANGELOG.md
  3. +6 −6 WORKSPACE
  4. +4 −12 guides/creating-a-custom-form-field-control.md
  5. +4 −15 guides/creating-a-custom-stepper-using-the-cdk-stepper.md
  6. +1 −1 guides/theming-your-components.md
  7. +20 −20 package.json
  8. +1 −1 src/cdk/a11y/a11y.md
  9. +8 −0 src/cdk/collections/data-source.ts
  10. +58 −0 src/cdk/overlay/position/flexible-connected-position-strategy.spec.ts
  11. +2 −2 src/cdk/overlay/position/flexible-connected-position-strategy.ts
  12. +8 −2 src/cdk/scrolling/virtual-for-of.ts
  13. +8 −6 src/cdk/stepper/stepper.ts
  14. +66 −1 src/cdk/table/table.spec.ts
  15. +19 −12 src/cdk/table/table.ts
  16. +3 −5 src/cdk/tree/tree.ts
  17. +26 −10 src/lib/button-toggle/button-toggle.spec.ts
  18. +4 −1 src/lib/button-toggle/button-toggle.ts
  19. +33 −2 src/lib/checkbox/checkbox.spec.ts
  20. +4 −1 src/lib/checkbox/checkbox.ts
  21. +19 −1 src/lib/chips/chip-list.spec.ts
  22. +18 −4 src/lib/chips/chip-list.ts
  23. +1 −0 src/lib/core/selection/pseudo-checkbox/pseudo-checkbox.scss
  24. +1 −1 src/lib/form-field/form-field.ts
  25. +32 −1 src/lib/list/selection-list.spec.ts
  26. +1 −1 src/lib/list/selection-list.ts
  27. +8 −0 src/lib/radio/radio.scss
  28. +16 −1 src/lib/radio/radio.spec.ts
  29. +1 −0 src/lib/radio/radio.ts
  30. +3 −4 src/lib/slider/slider.scss
  31. +13 −0 src/lib/stepper/stepper.spec.ts
  32. +3 −7 src/material-examples/cdk-custom-stepper-without-form/cdk-custom-stepper-without-form-example.html
  33. +3 −17 src/material-examples/cdk-custom-stepper-without-form/cdk-custom-stepper-without-form-example.ts
  34. +15 −10 src/material-examples/cdk-custom-stepper-without-form/example-custom-stepper.html
  35. +1 −0 src/material-examples/form-field-custom-control/form-field-custom-control-example.ts
  36. +2 −0 tools/public_api_guard/cdk/collections.d.ts
  37. +1 −1 tools/public_api_guard/cdk/table.d.ts
  38. +1 −1 tools/public_api_guard/generate-guard-tests.bzl
  39. +80 −86 yarn.lock
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@
/.circleci/** @jelbourn
/scripts/** @devversion @jelbourn
/test/** @devversion @jelbourn
/tools/**/!(*.d.ts) @devversion @jelbourn
/tools/** @devversion @jelbourn

# Public API golden files
/tools/public_api_guard/cdk/a11y.d.ts @jelbourn @devversion
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## 7.3.1 "liquidcrystal-sandwich" (2019-02-04)


### Bug Fixes

* **button:** not updating DOM node name if group name changes ([#14963](https://github.com/angular/material2/issues/14963)) ([37732cb](https://github.com/angular/material2/commit/37732cb))
* **cdk-stepper:** coercing selectedIndex value to a Number ([#14817](https://github.com/angular/material2/issues/14817)) ([b64c08d](https://github.com/angular/material2/commit/b64c08d))
* **checkbox:** not marked as touched immediately on blur with OnPush change detection ([#15001](https://github.com/angular/material2/issues/15001)) ([916c532](https://github.com/angular/material2/commit/916c532)), closes [#14980](https://github.com/angular/material2/issues/14980)
* **chips:** newly-added chips not being disabled when added to a disable list ([#14976](https://github.com/angular/material2/issues/14976)) ([c23512a](https://github.com/angular/material2/commit/c23512a))
* **examples:** fix form-field custom control `disabled` input ([#14957](https://github.com/angular/material2/issues/14957)) ([ce3926d](https://github.com/angular/material2/commit/ce3926d)), closes [/github.com/angular/angular/blob/e2c98fbe11272295c3827b0e54f859d283cd32bf/packages/forms/src/directives/reactive_errors.ts#L64](https://github.com//github.com/angular/angular/blob/e2c98fbe11272295c3827b0e54f859d283cd32bf/packages/forms/src/directives/reactive_errors.ts/issues/L64)
* **list:** selection list not picking up indirect descendants ([#15003](https://github.com/angular/material2/issues/15003)) ([6a07d0d](https://github.com/angular/material2/commit/6a07d0d)), closes [#15000](https://github.com/angular/material2/issues/15000)
* **MatPseudoCheckbox:** fix checkmark pseudo-element box-sizing ([#14971](https://github.com/angular/material2/issues/14971)) ([ba6b405](https://github.com/angular/material2/commit/ba6b405))
* **overlay:** unnecessarily pushing overlay if it is exactly as wide as the viewport ([#14975](https://github.com/angular/material2/issues/14975)) ([f4b4e61](https://github.com/angular/material2/commit/f4b4e61)), closes [#14968](https://github.com/angular/material2/issues/14968)
* **radio:** not updating DOM node name if group name changes ([#14950](https://github.com/angular/material2/issues/14950)) ([4d5c5d5](https://github.com/angular/material2/commit/4d5c5d5))
* **radio:** unable to click to select button if text is marked ([#14967](https://github.com/angular/material2/issues/14967)) ([81380d2](https://github.com/angular/material2/commit/81380d2)), closes [#14753](https://github.com/angular/material2/issues/14753)
* **slider:** focus ring showing when ancestor has focus monitoring ([#14960](https://github.com/angular/material2/issues/14960)) ([2ec9dff](https://github.com/angular/material2/commit/2ec9dff)), closes [#14958](https://github.com/angular/material2/issues/14958)
* **table:** allow for a caption to be projected ([#14965](https://github.com/angular/material2/issues/14965)) ([a8a6617](https://github.com/angular/material2/commit/a8a6617)), closes [#14948](https://github.com/angular/material2/issues/14948)
* **table:** Clarify unknown table column error ([#14947](https://github.com/angular/material2/issues/14947)) ([2782273](https://github.com/angular/material2/commit/2782273))
* **tree,scrolling:** don't require user DataSource to extend DataSource ([#14966](https://github.com/angular/material2/issues/14966)) ([0f9926a](https://github.com/angular/material2/commit/0f9926a))



# 7.3.0 "pyrite-pixie" (2019-01-28)


12 changes: 6 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -5,24 +5,24 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Add NodeJS rules (explicitly used for sass bundle rules)
http_archive(
name = "build_bazel_rules_nodejs",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.4.zip",
strip_prefix = "rules_nodejs-0.16.4",
url = "https://github.com/bazelbuild/rules_nodejs/archive/0.16.5.zip",
strip_prefix = "rules_nodejs-0.16.5",
)

# Add TypeScript rules
http_archive(
name = "build_bazel_rules_typescript",
# Explicitly depend on https://github.com/bazelbuild/rules_typescript/pull/327 which fixes the devserver
# for windows. Once this has been reviewed and merged, we can switch back to a normal release.
url = "https://github.com/bazelbuild/rules_typescript/archive/1bb017e2f9c58f96bac8ddda2ed4a170282bc58e.zip",
strip_prefix = "rules_typescript-1bb017e2f9c58f96bac8ddda2ed4a170282bc58e",
url = "https://github.com/bazelbuild/rules_typescript/archive/2e761b53ca465a140c4a265cb80887e7bcf61eb9.zip",
strip_prefix = "rules_typescript-2e761b53ca465a140c4a265cb80887e7bcf61eb9",
)

# Add Angular source and Bazel rules.
http_archive(
name = "angular",
url = "https://github.com/angular/angular/archive/7.1.3.zip",
strip_prefix = "angular-7.1.3",
url = "https://github.com/angular/angular/archive/7.2.1.zip",
strip_prefix = "angular-7.2.1",
)

# Add RxJS as repository because those are needed in order to build Angular from source.
16 changes: 4 additions & 12 deletions guides/creating-a-custom-form-field-control.md
Original file line number Diff line number Diff line change
@@ -307,22 +307,14 @@ make up our component.

```ts
@Input()
get disabled() {
return this._disabled;
}
set disabled(dis) {
this._disabled = coerceBooleanProperty(dis);
get disabled(): boolean { return this._disabled; }
set disabled(value: boolean) {
this._disabled = coerceBooleanProperty(value);
this._disabled ? this.parts.disable() : this.parts.enable();
this.stateChanges.next();
}
private _disabled = false;
```
```html
<input class="area" formControlName="area" size="3" [disabled]="disabled">
<span>&ndash;</span>
<input class="exchange" formControlName="exchange" size="3" [disabled]="disabled">
<span>&ndash;</span>
<input class="subscriber" formControlName="subscriber" size="4" [disabled]="disabled">
```

#### `errorState`

19 changes: 4 additions & 15 deletions guides/creating-a-custom-stepper-using-the-cdk-stepper.md
Original file line number Diff line number Diff line change
@@ -22,15 +22,6 @@ Now we are ready to create our custom stepper component. Therefore, we need to c
providers: [{ provide: CdkStepper, useExisting: CustomStepperComponent }]
})
export class CustomStepperComponent extends CdkStepper {
/** Whether the validity of previous steps should be checked or not */
linear: boolean;

/** The index of the selected step. */
selectedIndex: number;

/** The list of step components that the stepper is holding. */
steps: QueryList<CdkStep>;

onClick(index: number): void {
this.selectedIndex = index;
}
@@ -47,12 +38,10 @@ This is the HTML template of our custom stepper component:
<section class="container">
<header><h2>Step {{selectedIndex + 1}}/{{steps.length}}</h2></header>

<section *ngFor="let step of steps; let i = index;">
<div [style.display]="selectedIndex === i ? 'block' : 'none'">
<!-- Content from the CdkStep is projected here -->
<ng-container [ngTemplateOutlet]="step.content"></ng-container>
</div>
</section>
<div [style.display]="selected ? 'block' : 'none'">
<!-- Content from the CdkStep is projected here -->
<ng-container [ngTemplateOutlet]="selected.content"></ng-container>
</div>

<footer class="step-navigation-bar">
<button class="nav-button" cdkStepperPrevious>&larr;</button>
2 changes: 1 addition & 1 deletion guides/theming-your-components.md
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ For example, if building a custom carousel component:

// Define any styles affected by the theme.
.candy-carousel {
// Use mat-color to extract individual colors a palette.
// Use mat-color to extract individual colors from a palette.
background-color: mat-color($primary);
border-color: mat-color($accent, A400);
}
40 changes: 20 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -26,39 +26,39 @@
"check-release-output": "ts-node --project tools/release tools/release/check-release-output.ts",
"preinstall": "node ./tools/npm/check-npm.js"
},
"version": "7.3.0",
"version": "7.3.1",
"requiredAngularVersion": ">=7.0.0",
"dependencies": {
"@angular/animations": "^7.1.3",
"@angular/common": "^7.1.3",
"@angular/compiler": "^7.1.3",
"@angular/core": "^7.1.3",
"@angular/elements": "^7.1.3",
"@angular/forms": "^7.1.3",
"@angular/platform-browser": "^7.1.3",
"@angular/animations": "^7.2.1",
"@angular/common": "^7.2.1",
"@angular/compiler": "^7.2.1",
"@angular/core": "^7.2.1",
"@angular/elements": "^7.2.1",
"@angular/forms": "^7.2.1",
"@angular/platform-browser": "^7.2.1",
"@webcomponents/custom-elements": "^1.1.0",
"core-js": "^2.6.0",
"core-js": "^2.6.1",
"rxjs": "^6.3.3",
"systemjs": "0.19.43",
"tsickle": "^0.34.0",
"tslib": "^1.9.3",
"zone.js": "^0.8.29"
},
"devDependencies": {
"@angular-devkit/core": "^7.1.2",
"@angular-devkit/schematics": "^7.1.2",
"@angular/bazel": "^7.1.3",
"@angular/compiler-cli": "^7.1.3",
"@angular/http": "^7.1.3",
"@angular/platform-browser-dynamic": "^7.1.3",
"@angular/platform-server": "^7.1.3",
"@angular/router": "^7.1.3",
"@angular-devkit/core": "7.1.2",
"@angular-devkit/schematics": "7.1.2",
"@angular/bazel": "^7.2.1",
"@angular/compiler-cli": "^7.2.1",
"@angular/http": "^7.2.1",
"@angular/platform-browser-dynamic": "^7.2.1",
"@angular/platform-server": "^7.2.1",
"@angular/router": "^7.2.1",
"@bazel/ibazel": "^0.9.0",
"@bazel/karma": "0.22.0",
"@bazel/typescript": "0.22.0",
"@bazel/karma": "0.22.1",
"@bazel/typescript": "0.22.1",
"@firebase/app-types": "^0.3.2",
"@octokit/rest": "^15.9.4",
"@schematics/angular": "^7.1.2",
"@schematics/angular": "7.1.2",
"@types/browser-sync": "^0.0.42",
"@types/chalk": "^0.4.31",
"@types/fs-extra": "^4.0.3",
2 changes: 1 addition & 1 deletion src/cdk/a11y/a11y.md
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ details.

## LiveAnnouncer
`LiveAnnouncer` is used to announce messages for screen-reader users using an `aria-live` region.
See [the W3C's WAI-ARIA](https://www.w3.org/TR/wai-aria/states_and_properties#aria-live)
See [the W3C's WAI-ARIA](https://www.w3.org/WAI/PF/aria-1.1/states_and_properties#aria-live)
for more information on aria-live regions.

### Example
8 changes: 8 additions & 0 deletions src/cdk/collections/data-source.ts
Original file line number Diff line number Diff line change
@@ -29,3 +29,11 @@ export abstract class DataSource<T> {
*/
abstract disconnect(collectionViewer: CollectionViewer): void;
}

/** Checks whether an object is a data source. */
export function isDataSource(value: any): value is DataSource<any> {
// Check if the value is a DataSource by observing if it has a connect function. Cannot
// be checked as an `instanceof DataSource` since people could create their own sources
// that match the interface, but don't extend DataSource.
return value && typeof value.connect === 'function';
}
Original file line number Diff line number Diff line change
@@ -1261,6 +1261,9 @@ describe('FlexibleConnectedPositionStrategy', () => {
]);

attachOverlay({
// Set a large max-width to override the one that comes from the
// overlay structural styles. Otherwise the `width` will stop at the viewport width.
maxWidth: '200vw',
width: viewport.getViewportRect().width + 100,
positionStrategy
});
@@ -1292,6 +1295,9 @@ describe('FlexibleConnectedPositionStrategy', () => {
]);

attachOverlay({
// Set a large max-width to override the one that comes from the
// overlay structural styles. Otherwise the `width` will stop at the viewport width.
maxWidth: '200vw',
width: viewport.getViewportRect().width + 100,
positionStrategy
});
@@ -1869,6 +1875,58 @@ describe('FlexibleConnectedPositionStrategy', () => {
document.body.removeChild(veryLargeElement);
});

it('should not push the overlay if it is exactly as wide as the viewport', () => {
originElement.style.position = 'fixed';
originElement.style.top = '100px';
originElement.style.right = '0';

positionStrategy
.withFlexibleDimensions()
.withPush(true)
.withPositions([{
originX: 'center',
originY: 'bottom',
overlayX: 'center',
overlayY: 'top',
}]);

attachOverlay({
width: viewport.getViewportRect().width,
positionStrategy
});

const originRect = originElement.getBoundingClientRect();
const overlayRect = overlayRef.overlayElement.getBoundingClientRect();

expect(Math.floor(overlayRect.right)).toBe(Math.floor(originRect.right));
});

it('should not push the overlay if it is exactly as tall as the viewport', () => {
originElement.style.position = 'fixed';
originElement.style.left = '100px';
originElement.style.bottom = '0';

positionStrategy
.withFlexibleDimensions()
.withPush(true)
.withPositions([{
originX: 'start',
originY: 'bottom',
overlayX: 'start',
overlayY: 'bottom',
}]);

attachOverlay({
width: viewport.getViewportRect().height,
positionStrategy
});

const originRect = originElement.getBoundingClientRect();
const overlayRect = overlayRef.overlayElement.getBoundingClientRect();

expect(Math.floor(overlayRect.bottom)).toBe(Math.floor(originRect.bottom));
});

});

describe('onPositionChange with scrollable view properties', () => {
Original file line number Diff line number Diff line change
@@ -630,13 +630,13 @@ export class FlexibleConnectedPositionStrategy implements PositionStrategy {
// If the overlay fits completely within the bounds of the viewport, push it from whichever
// direction is goes off-screen. Otherwise, push the top-left corner such that its in the
// viewport and allow for the trailing end of the overlay to go out of bounds.
if (overlay.width < viewport.width) {
if (overlay.width <= viewport.width) {
pushX = overflowLeft || -overflowRight;
} else {
pushX = start.x < this._viewportMargin ? (viewport.left - scrollPosition.left) - start.x : 0;
}

if (overlay.height < viewport.height) {
if (overlay.height <= viewport.height) {
pushY = overflowTop || -overflowBottom;
} else {
pushY = start.y < this._viewportMargin ? (viewport.top - scrollPosition.top) - start.y : 0;
10 changes: 8 additions & 2 deletions src/cdk/scrolling/virtual-for-of.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,13 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ArrayDataSource, CollectionViewer, DataSource, ListRange} from '@angular/cdk/collections';
import {
ArrayDataSource,
CollectionViewer,
DataSource,
ListRange,
isDataSource,
} from '@angular/cdk/collections';
import {
Directive,
DoCheck,
@@ -82,7 +88,7 @@ export class CdkVirtualForOf<T> implements CollectionViewer, DoCheck, OnDestroy
}
set cdkVirtualForOf(value: DataSource<T> | Observable<T[]> | NgIterable<T>) {
this._cdkVirtualForOf = value;
const ds = value instanceof DataSource ? value :
const ds = isDataSource(value) ? value :
// Slice the value if its an NgIterable to ensure we're working with an array.
new ArrayDataSource<T>(
value instanceof Observable ? value : Array.prototype.slice.call(value || []));
14 changes: 8 additions & 6 deletions src/cdk/stepper/stepper.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

import {FocusableOption, FocusKeyManager} from '@angular/cdk/a11y';
import {Direction, Directionality} from '@angular/cdk/bidi';
import {coerceBooleanProperty} from '@angular/cdk/coercion';
import {coerceBooleanProperty, coerceNumberProperty} from '@angular/cdk/coercion';
import {END, ENTER, HOME, SPACE, hasModifierKey} from '@angular/cdk/keycodes';
import {
AfterViewInit,
@@ -276,19 +276,21 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
@Input()
get selectedIndex() { return this._selectedIndex; }
set selectedIndex(index: number) {
const newIndex = coerceNumberProperty(index);

if (this.steps) {
// Ensure that the index can't be out of bounds.
if (index < 0 || index > this.steps.length - 1) {
if (newIndex < 0 || newIndex > this.steps.length - 1) {
throw Error('cdkStepper: Cannot assign out-of-bounds value to `selectedIndex`.');
}

if (this._selectedIndex != index &&
!this._anyControlsInvalidOrPending(index) &&
(index >= this._selectedIndex || this.steps.toArray()[index].editable)) {
if (this._selectedIndex != newIndex &&
!this._anyControlsInvalidOrPending(newIndex) &&
(newIndex >= this._selectedIndex || this.steps.toArray()[newIndex].editable)) {
this._updateSelectedItemIndex(index);
}
} else {
this._selectedIndex = index;
this._selectedIndex = newIndex;
}
}
private _selectedIndex = 0;
Loading