Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(dialog): Reverse buttons when stacked; allow toggling auto-stack #3573

Merged
merged 4 commits into from
Sep 19, 2018

Conversation

kfranqueiro
Copy link
Contributor

@kfranqueiro kfranqueiro commented Sep 17, 2018

Fixes #3561.

BREAKING CHANGE: Adds hasClass and reverseButtons adapter APIs.

@kfranqueiro kfranqueiro assigned abhiomkar and unassigned acdvorak Sep 17, 2018
@kfranqueiro kfranqueiro requested review from abhiomkar and removed request for acdvorak September 17, 2018 19:08
dialog.autoStackButtons = false;
```

This will also be disabled if the `mdc-dialog--stacked` modifier class is applied manually to the root element before the
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this implemented in foundation? couldn't find logic which detects the existence of --stacked modifier class before auto stack.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's currently implemented in the component (where you left another comment), but I'm moving it to the foundation.


if (areButtonsStacked !== this.areButtonsStacked_) {
this.adapter_.reverseButtons();
this.areButtonsStacked_ = areButtonsStacked;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assignment can be outside if condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If it's outside the if, it's going to assign the value even when it's already the same value. Putting it inside the if makes it only assign the value when it's actually going to do something.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but I think we don't have to condition this since it is not toggling as in .reverseButton(). But this is fine too.

@@ -132,6 +140,10 @@ class MDCDialog extends MDCComponent {
this.listen('click', this.handleClick_);
this.listen(strings.OPENING_EVENT, this.handleOpening_);
this.listen(strings.CLOSING_EVENT, this.handleClosing_);

if (this.root_.classList.contains(MDCDialogFoundation.cssClasses.STACKED)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this logic be in foundation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Originally I put this in initialSyncWithDOM thinking that foundation.init could be too early for frameworks, but (1) I realized MDC React only calls foundation.init within componentDidMount anyway, and (2) I noticed we're doing stuff that's root-class-dependent even as soon as components are constructed (see drawer and top app bar's getDefaultFoundation), so if that doesn't cause a problem then this definitely won't.

I've moved it to foundation#init (required adding another adapter API).


if (areButtonsStacked !== this.areButtonsStacked_) {
this.adapter_.reverseButtons();
this.areButtonsStacked_ = areButtonsStacked;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, but I think we don't have to condition this since it is not toggling as in .reverseButton(). But this is fine too.

@codecov-io
Copy link

codecov-io commented Sep 19, 2018

Codecov Report

Merging #3573 into master will decrease coverage by 0.07%.
The diff coverage is 84.61%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3573      +/-   ##
==========================================
- Coverage   98.42%   98.35%   -0.08%     
==========================================
  Files         120      120              
  Lines        5133     5157      +24     
  Branches      637      640       +3     
==========================================
+ Hits         5052     5072      +20     
- Misses         81       85       +4
Impacted Files Coverage Δ
packages/mdc-dialog/foundation.js 100% <100%> (ø) ⬆️
packages/mdc-dialog/index.js 95.6% <50%> (-4.4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fcbef20...284e16c. Read the comment docs.

@kfranqueiro kfranqueiro merged commit 2e7805b into master Sep 19, 2018
@kfranqueiro kfranqueiro deleted the feat/dialog-stacked-reverse branch September 19, 2018 15:17
@jamesmfriedman jamesmfriedman mentioned this pull request Sep 26, 2018
49 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants