Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

md-chips: Add a chip onInputBlur #3364

Closed
websirnik opened this issue Jun 19, 2015 · 61 comments
Closed

md-chips: Add a chip onInputBlur #3364

websirnik opened this issue Jun 19, 2015 · 61 comments
Assignees
Labels
has: Pull Request A PR has been created to address this issue P2: required Issues that must be fixed. resolution: fixed
Milestone

Comments

@websirnik
Copy link

I think it's a good experience for md-chips to convert outstanding text to a chip when input loses focus.

Here is a use-case when it's relevant. User does not know that he needs to click enter to add a chip. When users clicks "Send email", no email has been captured.

2015-06-19 11_35_02

@jproby
Copy link

jproby commented Jun 23, 2015

👍

3 similar comments
@nitinhayaran
Copy link

👍

@reillydavis
Copy link

👍

@Nikesh
Copy link

Nikesh commented Jul 5, 2015

👍

@ThomasBurleson ThomasBurleson modified the milestone: 0.11.0 Jul 6, 2015
@ThomasBurleson ThomasBurleson modified the milestones: 0.11.0, REVISIT Jul 31, 2015
@ThomasBurleson ThomasBurleson assigned typotter and unassigned typotter Jul 31, 2015
@ThomasBurleson ThomasBurleson added needs: review This PR is waiting on review from the team and removed needs: review This PR is waiting on review from the team labels Jul 31, 2015
@bonatoc
Copy link

bonatoc commented Aug 5, 2015

In the meantime, you can still hack :

MdChipsCtrl.prototype.onInputBlur = function () {
  this.inputHasFocus = false;
  var chipBuffer = this.getChipBuffer();
  if (chipBuffer != "") { // REQUIRED, OTHERWISE YOU'D GET A BLANK CHIP
      this.appendChip(chipBuffer);
      this.resetChipBuffer();
  }
};

This is just replicating what is triggered by ENTER keycode, on MdChipsCtrl.prototype.inputKeydown.

@ThomasBurleson ThomasBurleson modified the milestones: 0.11.0, REVISIT Aug 10, 2015
@jestelle
Copy link

From the best I can tell, this is not explicitly specified in spec, but I would agree with the suggestion of the reporter.

@jelbourn
Copy link
Member

UX decision: Always add on blur

@bonatoc
Copy link

bonatoc commented Aug 14, 2015

Yay!

@zzo
Copy link

zzo commented Sep 11, 2015

+1

@maelfrize
Copy link

I'm happy about your UX decision. Our users are having the same issues when filling out forms with chips.
Looking forward to your fix :)

@janvandenberg
Copy link
Contributor

+1

@ThomasBurleson ThomasBurleson removed this from the 1.0-rc1 milestone Oct 27, 2015
@seanconnollydev
Copy link

+1

This should be re-opened. I have tried all of the recommended workarounds and some variations of my own and none of them work well with md-autocomplete.

@devversion devversion reopened this Jul 20, 2016
@devversion devversion assigned devversion and unassigned typotter Jul 20, 2016
@devversion devversion added P2: required Issues that must be fixed. and removed needs: review This PR is waiting on review from the team needs: UX team review labels Jul 20, 2016
@devversion devversion modified the milestones: - Backlog, 1.3.0 Jul 20, 2016
@devversion
Copy link
Member

I reopened that issue and we'll work on an attribute, which allows developers to add chips, on input blur.

devversion added a commit to devversion/material that referenced this issue Jul 21, 2016
* Allows developers to convert the remaining input text into a new chip on input blur.
  This is useful for example, when having chips for email addresses.

Closes angular#3364.
@devversion devversion added the has: Pull Request A PR has been created to address this issue label Jul 21, 2016
devversion added a commit to devversion/material that referenced this issue Aug 19, 2016
* Allows developers to convert the remaining input text into a new chip on input blur.
  This is useful for example, when having chips for email addresses.

Closes angular#3364.
jelbourn pushed a commit that referenced this issue Aug 23, 2016
* Allows developers to convert the remaining input text into a new chip on input blur.
  This is useful for example, when having chips for email addresses.

Closes #3364.
cgx added a commit to Alinto/sogo that referenced this issue Sep 2, 2016
The md-chips component has now the md-add-on-blur functionality.

See angular/material#3364
@jaggedsoft
Copy link

jaggedsoft commented Sep 9, 2016

+1 Thanks for the hack@jdeanwaite, works awesome!

@jaggedsoft
Copy link

jaggedsoft commented Sep 9, 2016

@jelbourn Thanks, I tried your commit in 1.1.1 and it works great,
Could you add this directive to md-contact-chips as well please? See: https://codepen.io/jaggedsoft/pen/wzKvrj
Edit: Unnecessary. Same result can be achieved with <md-chip-template>

@madeFromCode
Copy link

madeFromCode commented Sep 21, 2016

@devversion Very nice to have this functionality, however...

Using md-add-on-blur with auto-complete breaks the click functionality for the auto-complete list.

Edit: So I was able to fix it by modifying the code to check and see if the auto-complete list item is the new active element. I had to delay it with a 0 second timeout because the blur event fires before the list item becomes the new active element.

  setTimeout(function () { 
    // Only append the chip and reset the chip buffer if the chips and input ngModel is valid.
    if (!document.activeElement.hasAttribute('md-virtual-repeat') && this.addOnBlur && chipBuffer && isModelValid) {
        this.appendChip(chipBuffer);
        this.resetChipBuffer();
    }
    this.fromAutoComplete = false;
  }.bind(this));

It's not as elegant of a solution as I would like, but it works...

@ronbnsim
Copy link

+1

@bonatoc
Copy link

bonatoc commented Nov 24, 2016

Did not have time to check it yet, but hasn't this been addressed in 1.1.1 ?
https://github.com/angular/material/blob/master/CHANGELOG.md

bbc6c07

@kabb5
Copy link

kabb5 commented Dec 7, 2016

@bonatoc Yes, the changelog you linked to says "chips: md-add-on-blur functionality (#9095) (bbc6c07), closes #3364"

@mikila85
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has: Pull Request A PR has been created to address this issue P2: required Issues that must be fixed. resolution: fixed
Projects
None yet
Development

No branches or pull requests