-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-height fix for text area which is contained in a scroll container #1933
Conversation
I'm not sure, but I don't see a difference in behaviour between old and new. using win10, ff 40.0.3. If I use the scroll wheel, both versions scroll. ... |
probably, I use your test cases in a wrong way. How to reproduce? |
Hi @pmario
The behaviour for tiddlers without scroll containers is for both the same (I am referring to writing text in "A dummy Tiddler"). But old and new differ for text areas with scrollable parents. To see a difference,
-Felix |
ahh, I see. Sorry for the trouble. so +1 for the fix. tested with ff latest and MS Edge on win 10 :) |
No problem, glad you tested it and it works! :) -Felix |
Hi @Jermolene Could you please signal me, whether you are satisfied with the PR or not? It is important for TiddlyMap, otherwise working in fullscreen is not really possible, so I hope it is included in the next TiddlyWiki release. Thanks |
@felixhayashi, when I test "A dummy tiddler" in the new version, the behavior seems to have actually deteriorated from working fine in the old one to jumpy in the new one. Hit enter at the bottom to add some new lines. Can you confirm? |
Whoops. Yes. Not sure what is causing this, I'll need to fix that. |
It only happens for the very last tiddler in the river. If you open/create other tiddlers in the river and do as you described above, it works fine. Strange… |
Ok found the problem and will upload a new version in a minute. |
dee8c2d
to
f33b33f
Compare
element that has scrollbars. The wrapper element with the scroll bar does not need to be a direct parent of the text area. **update:** fixed a bug This is fixed now: TiddlyWiki#1933 (comment) The problem was the check in getScrollContainer()
f33b33f
to
ab92ea4
Compare
element that has scrollbars. The wrapper element with the scroll bar does not need to be a direct parent of the text area. **update:** fixed a bug This is fixed now: TiddlyWiki#1933 (comment) The problem was the check in getScrollContainer()
var container = this.getScrollContainer(domNode), | ||
scrollTop = container.scrollTop; | ||
// Measure the specified minimum height | ||
domNode.style.height = this.editMinHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Jermolene that is an interesting way to allow the user to use calc() and percent units… I mean you assign the minHeight to the domNode just to measure it and the override it again with "auto", that seems strange at first sight – but considering, that the user may enter values that are not pixels, it is very clever to calculate the height that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The purpose of the manoeuvre is actually to measure the 'natural' size of the content of the textarea so that we can then explicitly set the textarea itself to that size. If the user is manually sizing the textarea then none of this is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, then I misinterpreted this line. Thanks for the clarification.
Sorry @felixhayashi I'm only just having a look at this now. In principle I'm very keen on a fix, but I haven't yet investigated the approach you've taken or explored any unintended impact. |
Ah ok, thanks for telling me. Then I know you are aware of it. :) |
@felixhayashi, works like a charm now, thanks. |
@felixhayashi I haven't forgotten this PR! I will make some time to test it properly over the next couple of days |
Thanks @Jermolene. I appreciate very much that you are informing me. Please take your time, I agree this needs some thorough testing as it is an important widget :) |
element that has scrollbars. The wrapper element with the scroll bar does not need to be a direct parent of the text area. **update:** fixed a bug that came up in the discussion This is fixed now: TiddlyWiki#1933 (comment) The problem was the check in getScrollContainer()
ab92ea4
to
d3ab414
Compare
Just as a sidenote: I have tested this PR in all my wikis (Chrome + FF) the past weeks and it works without any problems. |
// Make sure that the dimensions of the textarea are recalculated | ||
$tw.utils.forceLayout(domNode); | ||
// Check that the scroll position is still visible before trying to scroll back to it | ||
scrollTop = Math.min(scrollTop,self.document.body.scrollHeight - window.innerHeight); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @felixhayashi my apologies. I'm going to focus on the backlog of pull requests for a few days, and wanted to start with this one!
Anyhow, your changes appear to have lost the logic here that checks that the scroll position is still visible. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Jermolene
This is intentional because I use scrollTop and not window.scrollTo()
scrollTop can be set to any integer value, with certain caveats:
If the element can't be scrolled (e.g. it has no overflow or if the element is non-scrollable), scrollTop is set to 0.
If set to a value less than 0, scrollTop is set to 0.
If set to a value greater than the maximum that the content can be scrolled, scrollTop is set to the maximum.https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop
So I do not need to do this check.
Moreover, the new code that accounts for situation with nested elements that act as scroll containers, the parent may not be the window object (as in the original/old code; also reflected in $tw.utils.getScrollPosition only looking at the window object) and the scrollHeight of relevance may not be the one of the body element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But feel free to thoroughly test it :)
Auto-height fix for text area which is contained in a scroll container
Yay! 😃 thanks @Jermolene |
No problem @felixhayashi I've just updated the prerelease too: http://tiddlywiki.com/prerelease |
Hi @Jermolene
Finally found the time to implement this (see #1575). Your suggested way for fixing was the way to go.
Description
Allows text areas to be auto-height while being wrapped in an
element that has scrollbars. The wrapper element with the
scroll bar does not need to be a direct parent of the text area.
Demo
For a demo of the new behaviour see:
http://wkpr.de/hosting/tmp/tw5/scrolling/new.html
The old (bad) behaviour can be viewed here:
http://wkpr.de/hosting/tmp/tw5/scrolling/old.html
-Felix