ngx-chips icon indicating copy to clipboard operation
ngx-chips copied to clipboard

triggered enter event twice with combined language/character

Open do-yeon opened this issue 6 years ago • 1 comments

PLEASE MAKE SURE THAT:

  • you searched similar issues online (9/10 issues in this repo are solved by googling, so please...do it)
  • you provide an online demo I can see without having to replicate your environment
  • you help me by debugging your issue, and if you can't, do go on filling out this form

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] support request/question

Notice: feature requests will be ignored, submit a PR if you'd like

Current behavior

Whenever I type in some words in Korean or unicode. it makes two tags. For example 테그입력 -> "테그입력" and "력" last alphabet becomes second tag.

Expected behavior

only one tag should appear.

Minimal reproduction of the problem with instructions (if applicable)

it can see on your demo page.

2018-12-25 7 58 55 2018-12-25 7 59 04

What do you use to build your app?. Please specify the version

Angular version:

ngx-chips version:

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Mac Chrome v 71.0.3578.98

do-yeon avatar Dec 25 '18 11:12 do-yeon

저는 이렇게 해결했습니다. 참고 하시길 바랍니다. *.html

<tag-input id="element"
                                 formControlName="contents"
                                 [modelAsStrings]="true"
                                 [placeholder]="'내용 추가'"
                                 [secondaryPlaceholder]="'내용 추가'"
                                 [onAdding]="onAdding"
                                 [onRemoving]="onRemoving"
                                 theme='primary'>
 </tag-input>

*.ts

onAdding(tag): Observable<any> {
    const lastChart = tag.substr(tag.length - 1);     // 입력된 값 중 마지막 글자만 가지고 옴
    const c = lastChart.charCodeAt(0);       // 마지막 글자 코드변환

    if (0x1100 <= c && c <= 0x11FF || 0x3130 <= c && c <= 0x318F || 0xAC00 <= c && c <= 0xD7A3) {
      if (tag.length === 1) {
        return
      }
    }
    return of(tag);
  }

venushiphop avatar Jan 29 '19 08:01 venushiphop