@@ -20,7 +20,6 @@ import 'package:angular_components/model/action/async_action.dart';
2020import 'package:angular_components/model/observable/observable.dart' ;
2121import 'package:angular_components/utils/angular/id/id.dart' ;
2222import 'package:angular_components/utils/browser/dom_service/dom_service.dart' ;
23- import 'package:angular_components/utils/disposer/disposable_callback.dart' ;
2423import '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 ///
0 commit comments