angular-ui / ui-tinymce

AngularUI wrapper for TinyMCE
MIT License
488 stars 371 forks source link

Prevent duplicate ID's #295

Closed roelplieger closed 7 years ago

roelplieger commented 7 years ago

We had a problem using multiple inline tinymce editors. Because the code used a timestamp for generating unique ID's some were generated in the same millisecond resulting in duplicate ID's. As a solution I wrote a service (which is a singleton) that provides a unique ID. All directives ask a unique ID from this service guaranteeing its uniqueness.

FYI: I also tried the supplied unit test agains the old code, then it fails which proves the problem.

Cheers, Roel Plieger.

deeg commented 7 years ago

It was actually doing this recently, and was changed by 15c64f14eab6668cc4c14d871a0c03bcfa35de82.

I just want to do some investigation tonight to see if there are any implications for changing that back.

I have another possible fix, for what that commit was trying to solve, so I will take another look tonight at everything.

roelplieger commented 7 years ago

Ok, checked it with the generatedIds var, this also passes my unit test so you don't need the service. I thought every directive would get its own instance so the counter var would start at zero all the time, but this isn't true (at least if the var is initialized above the return of course).

Bradleycorn commented 7 years ago

I'm running into the same issue (duplicate id's for multiple instances are generated with the same timestamp) ... Hope this PR can be resolved soon!

Also, love me some Phish band. Been touring since '94 ;)

ClickerMonkey commented 7 years ago

How in the world isn't this fixed yet - and how did someone think it was a good idea to use a timestamp?

deeg commented 7 years ago

@ClickerMonkey, thanks for the helpful input!