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

md-tab: md-on-select called on init #3243

Closed
jozsi opened this issue Jun 12, 2015 · 14 comments
Closed

md-tab: md-on-select called on init #3243

jozsi opened this issue Jun 12, 2015 · 14 comments
Assignees
Labels
needs: feedback The issue creator or community need to respond to questions in this issue
Milestone

Comments

@jozsi
Copy link

jozsi commented Jun 12, 2015

Since about yesterday (0.10.0-rc4 ~ master branch), the md-on-select of an md-tab gets
during the initialization of md-tabs. Previously it has been called only when a tab was explicitly selected.

Example - see console log

@e-oz
Copy link
Contributor

e-oz commented Jun 12, 2015

this bug affects one of my apps also. I have routing events assigned to on-select, so now users can't open desired page by URL and I can't use $state.go, because right after that on-select will trigger another one redirect.

@jo-me
Copy link

jo-me commented Jun 15, 2015

This is probably due to this: #3169 .
The events are incomplete if the tab-select-event is not being fired in all cases when a tab is selected (also automatically).
Your solution would probably be to start in an unselected state (not sure whether thats possible, I think I saw an issue regarding that recently). EDIT: found some: #3212, #3172

There is, however, still a bug in the latest version as the event is not coming when the tabs are loaded asynchronously.

@e-oz
Copy link
Contributor

e-oz commented Jun 15, 2015

@jo-me funny thing is I completely disagree with you and don't think on-select should be fired when tab is initially displayed :)

@jo-me
Copy link

jo-me commented Jun 15, 2015

Nothing wrong with disagreeing :)

IMO, as long as the md-tabs component automatically displays the first tab, the md-select event should get fired.
If you use it for navigation purposes, doesn't it show tab 1 as being active without showing the correct route?

@e-oz
Copy link
Contributor

e-oz commented Jun 15, 2015

@jo-me no, it triggers chaotic routing and ends up with "/#/" URL with default page rendered, so app is completely unusable (and I had to switch back to 0.9.8). I think separate event can satisfy both sides.

@jo-me
Copy link

jo-me commented Jun 15, 2015

I'm not familiar with your use case, but how about using the ng-click event instead?
This sounds like a closer match for your needs than md-select.

@e-oz
Copy link
Contributor

e-oz commented Jun 15, 2015

@jo-me good idea, thanks, but currently (with angular-material 0.10.0 and with 0.9.8, both) it gives exception about $apply:
screenshot 2015-06-15 22 34 51

But I will glad to switch to ng-click, if this bug will be fixed. Especially when 0.10 is new stable :)

@e-oz
Copy link
Contributor

e-oz commented Jun 15, 2015

I found solution: I just ignore first event and all works as expected. But I still hope ng-click bug will be fixed.

@robertmesserle
Copy link
Contributor

@e-oz I believe ng-click should work, but I am not 100% sure what your use-case looks like.

As for whether or not to fire the md-on-select event, it would make sense to me to fire the event if/when our code provides a value. But if you pre-populate the variable with a value of 0, it will not fire. If this makes sense to you, I will make sure that this functionality works. (I haven't tested, but logically, this seems like how I would expect it to work.)

@robertmesserle robertmesserle added the needs: feedback The issue creator or community need to respond to questions in this issue label Jul 21, 2015
@e-oz
Copy link
Contributor

e-oz commented Jul 22, 2015

@robertmesserle I've created codepen with my use-case and with instruction how to reproduce bug:
http://codepen.io/evgeniyoz/pen/BNOmKx?editors=101
(copied as gist also)

@robertmesserle
Copy link
Contributor

Ah, this is a separate issue, but I am committing a fix right now.

@robertmesserle
Copy link
Contributor

@e-oz Fix here 1b984ed

@e-oz
Copy link
Contributor

e-oz commented Jul 23, 2015

@robertmesserle thank you!

@jozsi
Copy link
Author

jozsi commented Jul 23, 2015

Using ng-click and @robertmesserle 's fix did indeed achieve the desired result. Thank you!

@jozsi jozsi closed this as completed Jul 23, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs: feedback The issue creator or community need to respond to questions in this issue
Projects
None yet
Development

No branches or pull requests

5 participants