简体   繁体   English

如何防止在字段上进行选项卡时选择angular-ui-select默认值

[英]How to prevent angular-ui-select default from being selected when tabbing over field

When tabbing over our angular-ui-select fields, the first value is chosen automatically, even though the user did not intend to select it. 当在我们的angular-ui-select字段上angular-ui-select ,即使用户不打算选择它,也会自动选择第一个值。

I checked GitHub and see this issue , which seems to contain a fix, but I don't want to edit the source code if there is a way to do what I need within the supported API. 我检查了GitHub并看到了这个问题 ,它似乎包含了一个修复程序,但如果有办法在支持的API中执行我需要的操作,我不想编辑源代码。

Please note: We are using angular-ui-select version 17.0 in our app. 请注意:我们在我们的应用程序中使用angular-ui-select版本17.0。 We had to stop at this version because it was the last version that allowed us to pass in an expression to the repeat attribute, rather than a string, which is critical to one of our major components. 我们不得不停在这个版本,因为它是允许我们将表达式传递给repeat属性的最后一个版本,而不是字符串,这对我们的一个主要组件至关重要。

Posting here because the CONTRIBUTING.md said to. 在这里发帖是因为CONTRIBUTING.md说的。

You can use remove-selected attribute to the <ui-select> tag: 您可以对<ui-select>标记使用remove-selected属性:

https://github.com/angular-ui/ui-select/issues/1672 https://github.com/angular-ui/ui-select/issues/1672

This came down to what I consider a bug in ui-select. 这归结为我认为ui-select中的错误。 If you have ui-select automatically open when the user tabs into the field, the first item is automatically selected for a single-select field. 如果您在用户选中字段时自动打开ui-select,则会自动为单选字段选择第一个项目。 I created a version of the code that doesn't do this and pushed it to bower. 我创建了一个不执行此操作的代码版本并将其推送给了bower。

Check it out here if you need it: https://github.com/granteagon/ui-select-temp 如果需要,请在此处查看: https//github.com/granteagon/ui-select-temp

I intend to build a version I can pull request, but there are a few tests that I need to update with the knowledge of not automatically selecting. 我打算构建一个我可以提取请求的版本,但是有一些测试我需要更新,并且不会自动选择。 Deadlines. 最后期限。

I also would like to refactor my changes to just fix a bug as opposed to using a new attribute, but that's my opinion and I have yet to clear it with the ui-select project team. 我还想重构我的更改以修复错误而不是使用新属性,但这是我的意见,我还没有用ui-select项目团队清除它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM