Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

fix(toolbar): add support in scrollshrink to ngshow/hide #5863

Closed
wants to merge 1 commit into from

Conversation

EladBezalel
Copy link
Member

updateToolbarHeight was not been called when ngShow or ngHide value has change which caused the toolbar to wait for the debounce to call updateToolbarHeight (5 sec)

KUDOS to @topherfangio for helping (and solving) me on this!

fixes #5706

`updateToolbarHeight` was not been called when `ngShow` or `ngHide` value has change which caused the toolbar to wait for the debounce to call `updateToolbarHeight` (5 sec)

fixes #5706
@EladBezalel EladBezalel added the needs: review This PR is waiting on review from the team label Nov 21, 2015
@ThomasBurleson
Copy link
Contributor

@topherfangio: 😀

// If the toolbar has ngShow or ngHide we need to update height immediately as it changed
// and not wait for $mdUtil.debounce to happen

if (attr.ngShow) { scope.$watch(attr.ngShow, updateToolbarHeight); }
Copy link
Contributor

Choose a reason for hiding this comment

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

@EladBezalel - why use scope.$watch() instead of attr.$observer()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Initially it was $observe but than topher came with this jem:
a quick excerpt from here regarding $observe verses $watch and why we need $watch here: http://stackoverflow.com/questions/14876112/angularjs-difference-between-the-observe-and-watch-methods

(If you try attrs.$observe('attr1') you'll get the string myModel.some_prop, which is probably not what you want.)

The $observe was returning the string ‘shouldShowToolbar’, not the value of that expression. And it was only firing once because the expression itself didn’t change.

Copy link
Contributor

Choose a reason for hiding this comment

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

As a note, I'm pretty sure the attr.$obseve('mdScrollShrink', onChangeScrollShrink); line above is also broken in the same way but I didn't get a chance to test.

Also, I highly doubt that people will be dynamically changing the scrollShrink attribute of the toolbar, so it's a VERY low priority to fix :-)

@ThomasBurleson ThomasBurleson added in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs and removed needs: review This PR is waiting on review from the team labels Nov 23, 2015
@ThomasBurleson ThomasBurleson added this to the 1.0-rc5 milestone Nov 23, 2015
@ThomasBurleson ThomasBurleson self-assigned this Nov 23, 2015
@EladBezalel EladBezalel deleted the fix/toolbar-scrollshrink-ngshow-nghide branch November 23, 2015 16:50
@ThomasBurleson ThomasBurleson removed the in progress Mainly for in progress PRs, but may be used for issues that require multiple PRs label Jan 19, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

md-scroll-shrink does not work with ng-show
3 participants