Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

Textarea styling #124

Open
tneil opened this issue May 14, 2012 · 19 comments
Open

Textarea styling #124

tneil opened this issue May 14, 2012 · 19 comments

Comments

@tneil
Copy link
Collaborator

tneil commented May 14, 2012

The HTML5 text area control should get some OS styling based on which OS it is running on

@alopix
Copy link

alopix commented Jun 12, 2012

I agree. The <textarea> is really ugly right now and doesn't fit to the rest of the design.

@Bjern
Copy link

Bjern commented Aug 23, 2012

I changed mine slightly, improving it, by editing the 0.9.3.js file. Go to line 116 and add textarea on the end. Code should look something like this.

bb.textInput.apply(root.querySelectorAll('input[type=text], [type=password], [type=tel], [type=url], [type=email], [type=number], [type=date], [type=time], [type=datetime], [type=month], [type=datetime-local], [type=color], textarea'));

Haven't tested this on all platforms AND it seems to ignore the rows showing pretty much one line. Definitely a styling issue as well as being a problem in the js. Maybe someone can take it further.

@rrenna
Copy link

rrenna commented Oct 12, 2012

This would be appreciated, quite the eye-sore currently

@karancan
Copy link
Contributor

Just basing this question off of what @Bjern spoke about: should textarea's be given the same styling as all the other input types like text? If so, textarea's would have the class bb-bb10-input (for bb10), etc.
Or should textarea's be their own entity separate from bb.textInput?

@tneil
Copy link
Collaborator Author

tneil commented Oct 15, 2012

I believe v0.9.4 "next" has some styling to it. But the end goal is to make the control an auto growing control based on text input to match the UX of the devices.

This requirement isn't just for BB10, it is for all of the OS versions from 5->10

@karancan
Copy link
Contributor

Alright so I have some code that allows the textarea to grow itself based on the amount of input but before pushing the code, I have a couple of questions:

1- Should the autogrow characteristic of the textarea be optional? Or does the user get to decide whether they want to use it or not?

The way I have it now is if you wanted the resizing, you would do this:

<textarea id="sample-text-area" rows="4" onkeyup="document.getElementById('sample-text-area').resize()"></textarea>

If you didn't want the resizing, you could just ignore the resize() function call.

2- I have added textarea's to the bb.textInput type so that it gets styling just like all the other textInput types. Is this ok? Or should I create bb.textArea ?

@tneil
Copy link
Collaborator Author

tneil commented Oct 22, 2012

The UX with the text area on BlackBerry is that you want it to grow in height by default. If you need a control that doesn't size vertically, then you would just use an input.

So I think enabling the resize by default would be great!

@karancan
Copy link
Contributor

Opened pull request #425 to try and address this issue

@xqliu
Copy link

xqliu commented Jan 12, 2013

Dear Karancan,

I have searched out bbui.js version 0.9.6.58 pulled from main stream today, and found this pull request has not been merged, also tried the sample app and the textarea is still not style according to standard UX and was not auto extened it's height based on length of the contents, do we have any plan on merge it? otherwise if we would like to use the textarea styling and height auto extend feature, a manual merge have to be done.

Thanks.

@tneil
Copy link
Collaborator Author

tneil commented Jan 12, 2013

While the pull request seemed to work in Ripple it did not work on actual devices which is why it was closed until further investigation could be done

@karancan
Copy link
Contributor

Yes, I reached a dead end with my investigation and then moved on to some other tasks. I'd be happy to work on it if anyone can provide pointers as to why it seemed to work in Ripple but not the device.

@xqliu
Copy link

xqliu commented Jan 12, 2013

Dear,

Are the styling not working or auto extend row number?

For the styling, since I totally used my own css definition and it works fine on both ripple and simulator, so I am not sure why your implementation is not working, I might not be able to help on this since I didn't look deep into the CSS auto applying mechanism on bbUI.

For the row number auto extend, it works on ripple and simulator, here are the solution I used

  • Define the hook
<textarea id="name" onkeyup="Util.resizeTextarea(this)"  onmouseup="Util.resizeTextarea(this)">
</textarea>
  • The utility.
        resizeTextarea : function (elem) {
            var contents = elem.value.split('\n'), newRows = 0, currentLine, currentRows = elem.rows;
            if (!elem.initialRows) {
                elem.initialRows = 1;
            }
            for (currentLine = 0; currentLine < contents.length; currentLine += 1) {
                if (contents[currentLine].length > elem.cols) {
                    newRows += Math.floor(contents[currentLine].length / elem.cols);
                    longLines += 1;
                }
            }
            newRows = newRows + contents.length;
            if (newRows !== currentRows) {
                elem.rows = (newRows < elem.initialRows ? elem.initialRows : newRows);
            }
        },

I don't have a dev alpha device so I am not sure whether it works on the device.

Regards.

@karancan
Copy link
Contributor

It would be nice if we could test this on the device !

@bert2002
Copy link

bert2002 commented Apr 9, 2013

I tried the code from litchi and the pull request from karancan and its not working in Ripple or on the Z10. If you need some one for testing, I am here :)

@miamon
Copy link

miamon commented May 29, 2014

some update about this issue? Thanks

@miamon
Copy link

miamon commented May 29, 2014

Just tested this solution http://labs.ft.com/2009/05/auto-growing-textareas/ and seems works fine

@tneil
Copy link
Collaborator Author

tneil commented May 30, 2014

Currently I'm focusing on the 10.3 styling, and then I might tackle this text area. I did find a way on another project on how to create a good auto growing text area... I just need to finish up the 10.3 styling work first.

@tneil tneil modified the milestones: Release v0.9.6, Release v1.0.0 May 30, 2014
@tneil
Copy link
Collaborator Author

tneil commented May 30, 2014

There's an interesting trick to get it to work which basically looks something like this:

<div>
  <div style="position:absolute;visibility:hidden"></div>
  <textarea style="height:100%;width:100%></textarea>
</div>

Then you make sure the fonts/margins/padding etc are all the same between the inner div and the text area. Everytime the text area is changed, you set the innerHTML of the div. That way the div grows with the text entered thus sizing the textarea that is set to 10% 👍 And since the div is hidden it is invisible behind the textarea that layers on top of it.

I have it working, just need to add it to bbUI

@tneil tneil removed this from the Release v0.9.6 milestone Jul 14, 2014
@tneil tneil added Request and removed BB6 labels Jul 17, 2014
@jyssh
Copy link

jyssh commented Dec 5, 2014

Any updates on this?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants