Skip to content
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

Merged
merged 1 commit into from
May 22, 2018

Conversation

josephperrott
Copy link
Member

Fixes #6726

Allows expansion indicator to be positioned at start or end of expansion panel header.

Copy link
Member

@crisbeto crisbeto left a 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.


/** 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';
Copy link
Member

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()">
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call

@josephperrott
Copy link
Member Author

Comments addressed, RTL is handled by CSS order of flex items in the flex container.


/** The positioning of the expansion indicator. */
@Input() togglePosition: MatAccordionTogglePosition = 'after';

Copy link
Member

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',
Copy link
Member

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?

Copy link
Member Author

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.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 2, 2017
@josephperrott josephperrott force-pushed the panel-indicator branch 2 times, most recently from 58047c4 to 7411347 Compare November 3, 2017 15:05
Copy link
Member

@crisbeto crisbeto left a 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)))
Copy link
Member

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

Copy link
Member Author

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];
Copy link
Member

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 {
Copy link
Member

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?

Copy link
Member Author

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 {
Copy link
Member

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;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added the action: merge The PR is ready for merge by the caretaker label Nov 8, 2017
@josephperrott josephperrott force-pushed the panel-indicator branch 3 times, most recently from 1fdaca5 to 97e3989 Compare November 20, 2017 16:56
@josephperrott josephperrott added the merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note label Nov 20, 2017
@josephperrott
Copy link
Member Author

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.

@josephperrott josephperrott force-pushed the panel-indicator branch 2 times, most recently from 7b0e73e to 60d5455 Compare December 6, 2017 21:05
@josephperrott josephperrott added the target: minor This PR is targeted for the next minor release label Dec 6, 2017
@josephperrott josephperrott force-pushed the panel-indicator branch 2 times, most recently from 2431ffc to 6a3f7ca Compare January 8, 2018 18:11
@josephperrott josephperrott force-pushed the panel-indicator branch 2 times, most recently from 0788d32 to e8c77c1 Compare January 12, 2018 16:02
@josephperrott josephperrott force-pushed the panel-indicator branch 5 times, most recently from 46e0bd3 to 99e2701 Compare April 4, 2018 16:19
@mmalerba
Copy link
Contributor

@josephperrott needs rebase, re-apply merge ready when done

@mmalerba mmalerba removed the action: merge The PR is ready for merge by the caretaker label Apr 18, 2018
@josephperrott josephperrott force-pushed the panel-indicator branch 6 times, most recently from b320840 to 1c3ff54 Compare May 3, 2018 00:46
@ngbot
Copy link

ngbot bot commented May 3, 2018

Hi @josephperrott! This PR has merge conflicts due to recent upstream merges.
Please help to unblock it by resolving these conflicts. Thanks!

@josephperrott josephperrott added the action: merge The PR is ready for merge by the caretaker label May 3, 2018
@josephperrott josephperrott removed the request for review from andrewseguin May 8, 2018 23:37
@mmalerba mmalerba merged commit 51d859f into angular:master May 22, 2018
mmalerba added a commit that referenced this pull request May 22, 2018
@mmalerba
Copy link
Contributor

@josephperrott This had to be reverted due to unexpected screenshot diffs in g3

@johnchristopherjones
Copy link

Any plans to complete this feature?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
@josephperrott josephperrott deleted the panel-indicator branch March 20, 2020 22:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow md-expansion-panel toggle to be placed at the beginning
7 participants