Skip to content

Commit bbd8c0e

Browse files
committed
fix(material/progress-spinner): fix setting diameter programmatically
1 parent 658b8fb commit bbd8c0e

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/material/progress-spinner/progress-spinner.spec.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ describe('MDC-based MatProgressSpinner', () => {
266266
expect(fixture.nativeElement.querySelector('svg').getAttribute('focusable')).toBe('false');
267267
});
268268

269-
it('should handle the number inputs being passed in as strings', () => {
269+
fit('should handle the number inputs being passed in as strings', () => {
270270
const fixture = TestBed.createComponent(ProgressSpinnerWithStringValues);
271271
const spinner = fixture.debugElement.query(By.directive(MatProgressSpinner))!;
272272
const svgElement = spinner.nativeElement.querySelector('svg');
@@ -277,8 +277,10 @@ describe('MDC-based MatProgressSpinner', () => {
277277
expect(spinner.componentInstance.strokeWidth).toBe(11);
278278
expect(spinner.componentInstance.value).toBe(25);
279279

280-
expect(spinner.nativeElement.style.width).toBe('37px');
281-
expect(spinner.nativeElement.style.height).toBe('37px');
280+
const {width, height} = spinner.nativeElement.getBoundingClientRect();
281+
282+
expect(width).toBe(37);
283+
expect(height).toBe(37);
282284

283285
expect(svgElement.clientWidth).toBe(37);
284286
expect(svgElement.clientHeight).toBe(37);
@@ -290,8 +292,9 @@ describe('MDC-based MatProgressSpinner', () => {
290292
let spinner = fixture.debugElement.query(By.directive(MatProgressSpinner))!;
291293
spinner.componentInstance.diameter = 32;
292294
fixture.detectChanges();
293-
expect(spinner.nativeElement.style.width).toBe('32px');
294-
expect(spinner.nativeElement.style.height).toBe('32px');
295+
const {width, height} = spinner.nativeElement.getBoundingClientRect();
296+
expect(width).toBe(32);
297+
expect(height).toBe(32);
295298
});
296299

297300
it('should be able to set a default diameter', () => {

src/material/progress-spinner/progress-spinner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ const BASE_STROKE_WIDTH = 10;
8080
'tabindex': '-1',
8181
'[class._mat-animation-noopable]': `_noopAnimations`,
8282
'[class.mdc-circular-progress--indeterminate]': 'mode === "indeterminate"',
83-
'[style.width.px]': 'diameter',
84-
'[style.height.px]': 'diameter',
83+
'[style.--mdc-circular-progress-size]': 'diameter + "px"',
84+
'[style.--mdc-circular-progress-active-indicator-width]': 'diameter + "px"',
8585
'[attr.aria-valuemin]': '0',
8686
'[attr.aria-valuemax]': '100',
8787
'[attr.aria-valuenow]': 'mode === "determinate" ? value : null',

0 commit comments

Comments
 (0)