ElemeFE / element

A Vue.js 2.0 UI Toolkit for Web
https://element.eleme.io/
MIT License
54.1k stars 14.64k forks source link

[Bug Report] Use "show-password" in the input component, click button for "show password", the cursor position will automatically move to the beginning #18573

Open duanmw opened 4 years ago

duanmw commented 4 years ago

Element UI version

2.13.0

OS/Browsers version

win10 / Chrome Version 79.0.3945.88

Vue version

2.6.1

Reproduction Link

https://codepen.io/duanmw/pen/YzPrdmv

Steps to reproduce

Go to codepen.io and run the password box demo on element's official website. After entering the password in the password box, the input cursor is at the end. image But after clicking the "Show Password" button, the cursor at this time will automatically move to the beginning of the password box. image

What is Expected?

Input prompt cursor position remains unchanged.

What is actually happening?

Input prompt cursor position changed to the beginning.

XiangXiaolong007 commented 4 years ago

me too

TimeLessQ commented 4 years ago

me too

StriveTo commented 4 years ago

me too

ppatch commented 4 years ago

me too +1

JackieCheung commented 4 years ago

This problem still exists in version 2.13.2, but the demo is normal

lijibing01 commented 4 years ago

me to

xiaofeng-bm commented 4 years ago

好像是浏览器的问题,测试了一下,新版chrome就存在这个问题,但是在360极速浏览器上就没这个问题了

xiaofeng-bm commented 4 years ago

1 经测试,这样可以解决问题

xiaofeng-bm commented 3 years ago

给出解决方案如下,大致思路就是讲原来的input组件内部两个文件copy出来,封装成自己的组件,然后在引入element后面(记得要在引入element后面)将你copy出来的input组件封装成全局组件,并且修改input组件288行focus方法,具体看下图。 Snipaste_2021-01-12_09-42-54 Snipaste_2021-01-12_14-26-03

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

NidhoggDJoking commented 1 year ago

1 经测试,这样可以解决问题

还是有很多公司一直使用的element的老版本进行开发的,这样的方法能解决问题但最好还是官方出手解决更为妥当. 除非老版本不在维护

NidhoggDJoking commented 1 year ago
mounted () {
          this.$watch(
          () => {
              return this.$refs.input.passwordVisible
          },
          (val) => {
                this.$refs.input.blur();
                this.$refs.input.focus();
              }
           )
       }

https://codepen.io/JokingLulu/pen/ZEqLROz