Closed Gankra closed 11 years ago
So I've got 4 tests, and got everything working, but there's a frustrating problem with Firefox and the tests. All the other browsers will update the computed height right away on import, but firefox evidently needs a few milliseconds (100 seems to work alright) to catch up. As a solution, I've add a setTimeout on autogrow when importing. This fixes the issue, but means that Firefox fails all the tests (because it's only figuring out the change happened when the setTimeout comes around).
Any thoughts on how to deal with this?
Anything in a setTimeout is considered async so your tests need to be async. You need to use the done
parameter in your tests to tell mocha to wait (up to 2seconds max) for the change to happen and then you call done(). Info on that: http://visionmedia.github.io/mocha/#asynchronous-code
I'd do a setTimeout of like 125ms and inside of that have all your checks and after your checks the done()
. By this time Firefox should have had enough time to compute it all and the tests should pass.
Ah, that works great (oh hai, triply nested callbacks...). All the autogrow calls are now async, too, so I guess that was necessary anyway.
I think this is ready for review.
Three things I might be interested in adding to this pull:
Thoughts?
autogrow
as one work, not camelcase. Only 1 had AutoGrow
. Others were Autogrow
or autowgrow
. Personally I think autogrow
makes more sense. When you say "autosave
is used everywhere else", do you mean in our code or in other projects? reflow
, would it make more sense to add a param for that to be like fixed
or autogrow
?Actually, now that I think about it, since autogrow leverages reflow, if you want to know whenever an autogrow occurs, you can just listen for reflows.
autosave
is lowercase. i.e. webkitfullscreenchange
or keypress
.autogrow
as a public method until it's requested? Unless you see a need right now for it. I can't think of one personally, other than turning it off and on, but not just one way. Also, maybe it could take properties to update the option on the fly like: autogrow({minHeight: '100px'})
?As for the events, good point. Maybe just note that in the docs in the events section under reflow?
I'm fine with leaving _autogrow as is. I'm perfectly comfortable calling _autogrow in my own code, especially since my coworkers are deathly afraid of ever updating a dependency, and therefore won't.
herpderp broke fullscreen; fixed.
Is there anything else needed? Can this be merged?
Most likely not. I just need a little time to test this. Checking out your other PR now.
Oh, and, buttons-test is the branch
Anything I can do to help this along?
Sorry, I've been sick :\
If you wanna test the hell out of this in all the browsers I trust you to merge it in. I will test all these again when this gets released in 0.2.2.
I've already tested the hell out of it (even in iOS), anything in particular?
Just IE9 and IE10 especially. IE11 if you have it, if not, no biggie.
Just noticed this corner case. Fixing those scrollbars was probably more hassle than it was worth.
Oh well.
Tested in Chrome, Firefox, Safari, IE10, IE10 (IE9 mode), and iOS (only fails a minor unit test about scrolling to anchors in preview mode). I do not have access to IE11.
One thing you may not have noticed is that this diff makes autogrow:true the default in the sample running in the docs. I do this because autogrow:true is the only way to get tolerable mobile support, as far as I'm concerned (nesting vertical scrollbars are, at best, extremely confusing in mobile). Using maxHeight will also mess up iOS support.
I'm not sure how you work around the issues with merge conflicts from the build directory. A bit nervous about fucking up your VC pattern. I've pushed what a think is a bearable merge to my own develop: https://github.com/Gankro/EpicEditor
That look right to push you?
@Gankro I'll take a look tonight. I'm a little worried about a default that changes will change the layout. Most editable textarea's, by default, do not grow as far as I know. TinyMCE you have to activate a plugin, browser textareas you manually drag it larger. wysihtml5, or whatever that one is, doesn't have it either. We can always have it on by default and see how many questions or comments we get about it, but I have a feeling it'll be "surprising" to people.
As for conflicts. Is the conflict just with the min.js? If so I just rebuild, commit merge.
Yea, that's what I did. There was a conflict in the actual proper js, but both of the changes were mine (changing two configs conflicted), and it was a trivial fix.
And the actual library's default is to not autogrow, it's just that the sample is set up to autogrow so that the docs page works better on mobile. I would also officially recommend that other people default to autogrowing if they wish to better support mobile.
As far as messing up the doc's layout, it shouldn't. All it will do it make the rest of the page's content shift up and down, which is basically what html/css is designed for.
Whether enabling autogrow will clobber other people's layouts is a different question. I would say it's a definite posibility, although any layout that is just using it as an otherwise normal text box should probably be fine (as the height of the textbox shouldn't matter much).
Although I could see it growing so tall that it punches through some container and screws up some stuff.
Oh! I dont care about the docs layout. Thought you meant the library's default :) Disregard my concern then. I was just worried it'd start growing on people's sites and they wouldnt know why until they looked at the docs. If they explicitly want to turn on autogrow then they assume all the problems with the layout. There's no way we could think of every edge case.
Went ahead and pushed this. Willing to take any flak if it blows up in someone's face.
Rad! Sounds good to me. I'll play with it while im at OSCON too.
Tested in Chrome, Safari, FF22, IE10.
No tests yet, working on it.