-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(expansion): allow expansion indicator positioning. #8199
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the couple of comments below, it doesn't look like this handles RTL.
src/lib/expansion/accordion.ts
Outdated
|
||
/** Workaround for https://github.com/angular/angular/issues/17849 */ | ||
export const _CdkAccordion = CdkAccordion; | ||
|
||
/** MatAccordion's display modes. */ | ||
export type MatAccordionDisplayMode = 'default' | 'flat'; | ||
|
||
|
||
/** MatAccordion's toggle positions. */ | ||
export type MatAccordionTogglePosition = 'start' | 'end'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere else we use before
and after
for these kinds of inputs.
@@ -3,5 +3,7 @@ | |||
<ng-content select="mat-panel-description"></ng-content> | |||
<ng-content></ng-content> | |||
</span> | |||
<span [@indicatorRotate]="_getExpandedState()" *ngIf="_showToggle()" | |||
class="mat-expansion-indicator"></span> | |||
<div class="mat-expansion-indicator-container" [style.order]="_indicatorOrder()"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be more appropriate to toggle a class that sets the order
. It also makes it easier to handle RTL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call
c5dd84f
to
6c79470
Compare
Comments addressed, RTL is handled by CSS |
6c79470
to
82e8189
Compare
src/lib/expansion/accordion.ts
Outdated
|
||
/** The positioning of the expansion indicator. */ | ||
@Input() togglePosition: MatAccordionTogglePosition = 'after'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: there a bit too many newlines above and below this input.
expect(arrow.style.transform).toBe('rotate(225deg)', 'Expected 225 degree rotation.'); | ||
})); | ||
|
||
it('should update the indicator position when the position is set programmatically', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a test that verifies that the position still works when it's set on the accordion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also added a test for displayMode since it looks like that was missing in the tests as well.
58047c4
to
7411347
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, apply the merge ready label when the lint warning is sorted out.
this._parentChangeSubscription = merge( | ||
panel.opened, | ||
panel.closed, | ||
panel._inputChanges.pipe(filter(changes => !!(changes.hideToggle || changes.disabled))) | ||
merge(...changeSubjects).pipe( | ||
filter(changes => !!(changes.hideToggle || changes.disabled || changes.togglePosition))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need !!
in conditionals, only when the value is returned or stored for later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like filter
requires the value returned to be boolean
, and without the coercion the returned type is SimpleChanges
@Host() public panel: MatExpansionPanel, | ||
private _element: ElementRef, | ||
private _focusMonitor: FocusMonitor, | ||
private _changeDetectorRef: ChangeDetectorRef) { | ||
|
||
let changeSubjects = [panel._inputChanges]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't care here that these are Subjects, just that they're observables. I'd call this changeStreams
return !this.panel.hideToggle && !this.panel.disabled; | ||
} | ||
|
||
_placeIndicatorBefore(): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this function serve any value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method determines the ordering of the content in the header.
@@ -132,10 +141,14 @@ export class MatExpansionPanelHeader implements OnDestroy { | |||
} | |||
|
|||
/** Gets whether the expand indicator should be shown. */ | |||
_showToggle(): boolean { | |||
_showIndicator(): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_isToggleVisible
?
/** The positioning of the expansion indicator. */ | ||
@Input() | ||
get togglePosition(): MatAccordionTogglePosition { | ||
return this.accordion ? this.accordion.togglePosition : this._togglePosition; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the more specific position trump the parent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the hideToggle
value goes based on parent's value even if the child is defined so I went with the same. There is a strong argument that they both should be changed.
7411347
to
f201810
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
1fdaca5
to
97e3989
Compare
Caretaker: This change fixes the spacing of the expansion panel header to be even regardless of content of the title. This difference can be seen in the screenshot tests. |
7b0e73e
to
60d5455
Compare
2431ffc
to
6a3f7ca
Compare
0788d32
to
e8c77c1
Compare
e8c77c1
to
d300373
Compare
d300373
to
fb5565c
Compare
46e0bd3
to
99e2701
Compare
@josephperrott needs rebase, re-apply |
b320840
to
1c3ff54
Compare
Hi @josephperrott! This PR has merge conflicts due to recent upstream merges. |
1c3ff54
to
7ba0aff
Compare
@josephperrott This had to be reverted due to unexpected screenshot diffs in g3 |
Any plans to complete this feature? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Fixes #6726
Allows expansion indicator to be positioned at start or end of expansion panel header.