Skip to content

Commit 2361983

Browse files
crisbetoandrewseguin
authored andcommitted
fix(progress-spinner): spinner with narrower stroke not taking up entire element (#7686)
Fixes spinners that have a stroke smaller than the default not taking up the entire available space. Fixes #7674.
1 parent 7fe1b81 commit 2361983

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,15 @@ describe('MatProgressSpinner', () => {
103103
it('should allow a custom stroke width', () => {
104104
const fixture = TestBed.createComponent(ProgressSpinnerCustomStrokeWidth);
105105
const circleElement = fixture.nativeElement.querySelector('circle');
106+
const svgElement = fixture.nativeElement.querySelector('svg');
106107

107108
fixture.componentInstance.strokeWidth = 40;
108109
fixture.detectChanges();
109110

110111
expect(parseInt(circleElement.style.strokeWidth))
111112
.toBe(40, 'Expected the custom stroke width to be applied to the circle element.');
113+
expect(svgElement.getAttribute('viewBox'))
114+
.toBe('0 0 130 130', 'Expected the viewBox to be adjusted based on the stroke width.');
112115
});
113116

114117
it('should expand the host element if the stroke width is greater than the default', () => {

src/lib/progress-spinner/progress-spinner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
153153

154154
/** The view box of the spinner's svg element. */
155155
get _viewBox() {
156-
return `0 0 ${this._elementSize} ${this._elementSize}`;
156+
const viewBox = this._circleRadius * 2 + this.strokeWidth;
157+
return `0 0 ${viewBox} ${viewBox}`;
157158
}
158159

159160
/** The stroke circumference of the svg circle. */

0 commit comments

Comments
 (0)