GithubHelp home page GithubHelp logo

select 使用查询功能,在electron下,tab切换到输入后第一次中文输入法,无法展示查询下拉 about ng-zorro-antd HOT 2 OPEN

chenweihan avatar chenweihan commented on May 19, 2024
select 使用查询功能,在electron下,tab切换到输入后第一次中文输入法,无法展示查询下拉

from ng-zorro-antd.

Comments (2)

zorro-bot avatar zorro-bot commented on May 19, 2024

Translation of this issue:

SELECT uses the query function. Under Electron, the first Chinese input method of TAB switch to the input is not displayed in the query.

REPRODUCTION LINK

[https://github.com/maximegris/angular-Electron] (https://github.com/maximegris/angular-Electron)

STEPS To Reproduce

SELECT uses the query function. Under Electron, the Tab switch to the first Chinese input method after the input is input.
The problem has been basically positioned. Check the source code. Select.comPonent.ts uses the keydown event to switch the hidden state of the pull DOM.

In the browser, the Chinese input method will trigger the KEYDOWN event, everything is normal.
In Electron, the Chinese input method will not trigger the Keydown event, and the drop -down DOM cannot be displayed. If the Keydown event is triggered in the future, it will be normal. It will only appear in the TAB switch to select (if the click has been activated), the Chinese input method will not trigger the keydown event, so that the query is not displayed.

test environment:
Download the code from https://github.com/maximegris/angular-Electron, and then use the DEV mode
NPM Run Electron: SERVE monitor port 4200, and start the source code of NG-Zorro-ATD locally to adjust the verification.

What is exfected?

Can increase the input method event monitoring or listening value changes to trigger, so that it can be compatible with the Electron environment

What is actually happy?

In the Electron environment, Chinese input method, TAB switch to select cannot show drop -down search

| ENVIRONMENT | Info |
| --- | --- | |
| NG-Zorro-ATD | 14.3.0 |
| Browser | Electron |

from ng-zorro-antd.

chenweihan avatar chenweihan commented on May 19, 2024

由于electron中的浏览器和web环境浏览器在中文输入法事件的差异化造成ng-zorron的select组件出现BUG:

具体场景:
比如当tab切换到select的时候,第一次中文输入法输入汉字 "发发发",会按键"fff"拼出"发发发".

web环境浏览器中,输入"fff"的同时会在input框中同时输入"fff",在中文输入法最后确认的时候会使用"发发发"替换"fff".
electron环境浏览器中,输入"fff"的同时不会在input框中输入任何字符,在中文输入法最后确认的时候会使用"发发发"直接放到输入框
翻看源码:select组件监听了keydown事件监听下拉查询框组件渲染,在electron中的中文输入法最后确认回车或者空格输入到input并不会触发keydown事件,从而不会在tab切换到select查询的第一使用中文输入法触发下拉查询框组件渲染,同时渲染下拉查询框组件渲染后就不会再重新渲染,所以只会出现在第一次中。

满足输入有值的条件,渲染下拉查询框组件目前2个修复方案:

修复方案1绑定中文输入法事件触发:考虑当前使用的keydown事件绑定到普通div上的,处理逻辑在当前select组件里,中文输入法的监听事件只能绑定到input等输入上。而包含输入组件的input最终在select组件下属嵌套层级孙级组件内,需要熟悉内部逻辑,处理组件通信,该方案跨组件修改代码。

修复方案2监听输入值变化触发:最终输入法确认到input后,input值的change事件会被触发,在select组件有孙级input值change事件的通知,可以在该处,同时判断是输入框没值的时候(第一次没值,尽可能减少影响范围),触发原有keydown事件的逻辑。

目前已采取修复方案2,快速修复,优先使用起来,建议使用修复方案1。

from ng-zorro-antd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.