Skip to content
This repository was archived by the owner on May 20, 2023. It is now read-only.

Commit 6c6a2e4

Browse files
Googlernshahan
authored andcommitted
Automated g4 rollback of changelist 243324798.
*** Reason for rollback *** Breaks internal project tests *** Original change description *** In accordance with DeferredContentAware best practices *** PiperOrigin-RevId: 243398462
1 parent 14ec2f4 commit 6c6a2e4

File tree

3 files changed

+13
-66
lines changed

3 files changed

+13
-66
lines changed

angular_components/lib/material_expansionpanel/material_expansionpanel.dart

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import 'package:angular_components/model/action/async_action.dart';
2020
import 'package:angular_components/model/observable/observable.dart';
2121
import 'package:angular_components/utils/angular/id/id.dart';
2222
import 'package:angular_components/utils/browser/dom_service/dom_service.dart';
23-
import 'package:angular_components/utils/disposer/disposable_callback.dart';
2423
import 'package:angular_components/utils/disposer/disposer.dart';
2524

2625
/// A material-styled expansion-panel.
@@ -138,28 +137,10 @@ class MaterialExpansionPanel
138137
@ViewChild('mainPanel')
139138
set mainPanel(HtmlElement mainPanel) {
140139
_mainPanel = mainPanel;
141-
142-
final transitionCheck = DisposableCallback(() {
143-
// If we have a transition, turn off deferred content when it finishes
144-
// closing. If we don't (because style mixins/overrides/disabled in tests)
145-
// just forward the isExpanded change event.
146-
if (_mainPanelHasHeightTransition) {
147-
_disposer.addStreamSubscription(_mainPanel.onTransitionEnd.listen((_) {
148-
// Clear height override so it will match the active child's height.
149-
_mainPanel.style.height = '';
150-
// If we just finished closing, let deferred content stop rendering
151-
// the panel body.
152-
if (!isExpanded) _contentVisible.add(false);
153-
}));
154-
} else {
155-
_disposer.addStreamSubscription(isExpandedChange.listen((expanded) {
156-
// Just check for false (closed). Open (true) is always done first.
157-
if (!expanded) _contentVisible.add(false);
158-
}));
159-
}
160-
});
161-
_domService.scheduleRead(transitionCheck);
162-
_disposer.addDisposable(transitionCheck);
140+
_disposer.addStreamSubscription(_mainPanel.onTransitionEnd.listen((_) {
141+
// Clear height override so it will match the active child's height.
142+
_mainPanel.style.height = '';
143+
}));
163144
}
164145

165146
HtmlElement _headerPanel;
@@ -238,8 +219,7 @@ class MaterialExpansionPanel
238219
StreamController<bool>.broadcast(sync: true);
239220

240221
@override
241-
Stream<bool> get contentVisible => _contentVisible.stream;
242-
final _contentVisible = StreamController<bool>.broadcast(sync: true);
222+
Stream<bool> get contentVisible => isExpandedChange;
243223

244224
/// Whether a different panel in the set is currently expanded.
245225
///
@@ -542,11 +522,7 @@ class MaterialExpansionPanel
542522
stream.add(actionCtrl.action);
543523
var stateWasInitialized = initialized;
544524
actionCtrl.execute(() {
545-
// Update our state before redrawing. State changes need to occur before
546-
// follow ups (animation or autofocus) so that styles and deferred content
547-
// can update.
548525
_isExpanded.value = expand;
549-
if (expand) _contentVisible.add(true);
550526
if (byUserAction) _isExpandedChangeByUserAction.add(expand);
551527
_changeDetector.markForCheck();
552528
if (expand && _focusableItem != null) {
@@ -617,9 +593,10 @@ class MaterialExpansionPanel
617593
final contentHeight = _mainContent.scrollHeight;
618594
var expandedPanelHeight = '';
619595

596+
final mainPanelStyle = _mainPanel.getComputedStyle();
620597
// Do our best to make sure that onTransitionEnd will fire later.
621598
final hasHeightTransition =
622-
contentHeight > 0 && _mainPanelHasHeightTransition;
599+
contentHeight > 0 && mainPanelStyle.transition.contains('height');
623600

624601
if (hasHeightTransition) {
625602
// If the content-wrapper has a top margin, it is not reflected in the
@@ -630,12 +607,6 @@ class MaterialExpansionPanel
630607
return expandedPanelHeight;
631608
}
632609

633-
bool get _mainPanelHasHeightTransition {
634-
final mainPanelStyle = _mainPanel.getComputedStyle();
635-
// Do our best to make sure that onTransitionEnd will fire later.
636-
return mainPanelStyle.transition.contains('height');
637-
}
638-
639610
/// Reads the DOM state to calculate the height of the header in its
640611
/// current condition.
641612
///

angular_components/lib/material_expansionpanel/material_expansionpanel.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<!-- Expanded section -->
5656
<main [class.hidden]="!isExpanded" #mainPanel role="presentation" autoId #mainId="autoId">
57-
<div #mainContent *deferredContent="forceContent: forceContentWhenClosed">
57+
<div #mainContent *deferredContent="true;forceContent: forceContentWhenClosed">
5858
<div #contentWrapper class="content-wrapper" [class.hidden-header]="hideExpandedHeader">
5959
<material-icon
6060
*ngIf="shouldShowHiddenHeaderExpandIcon && shouldExpandOnLeft"

angular_components/lib/material_expansionpanel/material_expansionpanel.scss

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,18 @@
5858
}
5959
}
6060

61-
// It is impossible to change 'just' the transition function for visibility in hte hidden style,
62-
// so use a mixin to keep everything consistent except that.
63-
@mixin header-transition($visibility_function) {
64-
transition: height $mat-transition $mat-transition-standard,
65-
min-height $mat-transition $mat-transition-standard,
66-
opacity $mat-transition-slow $mat-transition-standard,
67-
visibility $mat-transition-slow $visibility_function;
68-
}
69-
7061
header {
7162
display: flex;
7263
color: $mat-transparent-black;
73-
// When switching to expanded, turn visibility on at the start.
74-
@include header-transition(step-start);
75-
visibility: inherit;
64+
transition: height $mat-transition $mat-transition-standard,
65+
min-height $mat-transition $mat-transition-standard,
66+
opacity $mat-transition-slow $mat-transition-standard;
7667

7768
&.hidden {
7869
min-height: 0;
7970
height: 0;
8071
opacity: 0;
8172
overflow: hidden;
82-
// When switching to hidden, don't turn off visibility until the end.
83-
@include header-transition(step-end);
84-
visibility: hidden;
8573
}
8674
}
8775

@@ -144,29 +132,17 @@ header {
144132
padding-right: $mat-grid * 2;
145133
}
146134

147-
// It is impossible to change 'just' the transition function for visibility in hte hidden style,
148-
// so use a mixin to keep everything consistent except that.
149-
@mixin main-transition($visibility-function) {
150-
transition: height $mat-transition $mat-transition-standard,
151-
opacity $mat-transition $mat-transition-standard,
152-
visibility $mat-transition $visibility-function;
153-
}
154-
155135
main {
156136
max-height: 100%;
157137
opacity: 1;
158138
overflow: hidden;
159-
// When switching to expanded, turn visibility on at the start.
160-
@include main-transition(step-start);
161-
visibility: inherit;
139+
transition: height $mat-transition $mat-transition-standard,
140+
opacity $mat-transition $mat-transition-standard;
162141
width: 100%;
163142

164143
&.hidden {
165144
height: 0;
166145
opacity: 0;
167-
// When switching to hidden, don't turn off visibility until the end.
168-
@include main-transition(step-end);
169-
visibility: hidden;
170146
}
171147
}
172148

0 commit comments

Comments
 (0)