question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

I would like to add md-textarea. From what I’ve tried(c&p md-input code, changing selector and template), it should be pretty straightforward, as it just worked without any changes to style or the component itself.

The differences between input and textarea are

  • textarea doesn’t have type, step, list attributes
  • textarea might have auto expand/size(probably not needed in the first iteration)

Since 90% of the component is made of annotations, and those cannot be inherited, the way to go(I think) might be either to extend selector

selector: 'md-input,md-textarea',

and use ElementRef to check which selector matched(unless there’s a better way I don’t know of) and *ngIfthe template to either <input> or <textarea>.

or keep only one selector(that is md-input), and add md-textarea as attribute, and *ngIf the template depending on that.

In both cases I’d be needed add check that type was not added along <md-textarea> or md-textarea, because of _convertValueForInputType, there won’t be no need to do anything with step or list, since those simply won’t be on the *ngIf’d template.

Thoughts?


as for autosize, there’s this tiny thing https://github.com/stevepapa/angular2-autosize

import { ElementRef, HostListener, Directive} from 'angular2/core';

@Directive({
    selector: 'textarea[autosize]'
})

export class Autosize {
 @HostListener('input',['$event.target'])
  onInput(textArea) {
    this.adjust();
  }
  constructor(public element: ElementRef){
  }
  ngOnInit(){
    this.adjust();
  }
  adjust(){
    this.element.nativeElement.style.overflow = 'hidden';
    this.element.nativeElement.style.height = 'auto';
    this.element.nativeElement.style.height = this.element.nativeElement.scrollHeight + "px";
  }
}

which utilizes scrollHeight, which is apparently supported by most browsers https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:26
  • Comments:21 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
fxckcommented, Oct 27, 2016

It’s in master, but not released on npm.

6reactions
alvaro450commented, Aug 16, 2016

@jelbourn @kara, when do you guys think text area will make it to material components?

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Textarea element - HTML: HyperText Markup Language
The <textarea> HTML element represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable ...
Read more >
HTMLTextAreaElement - Web APIs | MDN
The HTMLTextAreaElement interface provides special properties ...
Read more >
HTMLTextAreaElement.labels - Web APIs | MDN
A NodeList containing the <label> elements associated with the < ...
Read more >
HTMLTextAreaElement: selectionchange event - Web APIs
The selectionchange event of the Selection API is fired when ...
Read more >
HTMLTextAreaElement: select event - Web APIs | MDN
The select event fires when some text has been selected.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found