Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue3: Fix problematic disabled boolean attributes #11746

Closed
4 tasks
cnotv opened this issue Aug 28, 2024 · 4 comments · Fixed by #11824
Closed
4 tasks

Vue3: Fix problematic disabled boolean attributes #11746

cnotv opened this issue Aug 28, 2024 · 4 comments · Fixed by #11824
Assignees
Labels
area/vue3 Bugs and technical debts as outcome to the Vue3 migration kind/tech-debt Technical debt QA/None
Milestone

Comments

@cnotv
Copy link
Contributor

cnotv commented Aug 28, 2024

Description

As identified by @momesgin, in Vue3 the disabled attributed is handled differently.

Quoting our notes:

Stylings may not apply properly to some disabled, selected or focused elements(e.g. div)
In Vue 2, setting false to the value of an attribute would remove the attribute from being rendered. When doing this in Vue 3, false is considered a valid value, so the attribute will be rendered, to fix this you can pass null to the attribute's value instead
E.g.

<div :disabled="!opt.enabled">...</div>

should be converted to

<div :disabled="opt.enabled ? null : true">...</div>

More info: https://v3-migration.vuejs.org/breaking-changes/attribute-coercion.html

Affected components

The following components have been identified to have potentially problematic usages of :disabled. This isn't a comprehensive list, but is a good starting point for identifying which patterns we might need to look out for in order to completely resolve this issue.

  • pkg/harvester-manager/list/harvesterhci.io.management.cluster.vue
  • shell/components/ActionMenu.vue
  • shell/pages/c/_cluster/istio/index.vue
  • shell/pages/c/_cluster/monitoring/index.vue
@cnotv cnotv added kind/tech-debt Technical debt area/vue3 Bugs and technical debts as outcome to the Vue3 migration labels Aug 28, 2024
@cnotv cnotv added this to the v2.10.0 milestone Aug 28, 2024
@momesgin momesgin self-assigned this Aug 28, 2024
@momesgin momesgin changed the title Correct globally issues with disabled attributes handled differently in Vue3 Vue3: Fix problematic disabled boolean attributes Sep 4, 2024
@momesgin
Copy link
Member

momesgin commented Sep 4, 2024

I've updated the description:

  • removed shell/components/form/KeyValue.vue item since all the disabled cases in that file are on the tags that are supporting boolean attributes
  • removed shell/components/nav/NamespaceFilter.vue item since it's been covered in another PR

@cnotv
Copy link
Contributor Author

cnotv commented Sep 4, 2024

I was trying to use this flag in TS for this issue, but for some reasons it does not work 🤔
https://github.com/vuejs/language-tools/blob/master/packages/language-core/schemas/vue-tsconfig.schema.json#L43

@momesgin
Copy link
Member

momesgin commented Sep 4, 2024

I was trying to use this flag in TS for this issue, but for some reasons it does not work 🤔 https://github.com/vuejs/language-tools/blob/master/packages/language-core/schemas/vue-tsconfig.schema.json#L43

it would be ideal if we could add this somewhere in the ts config or eslint rules, but I think the chances of making this mistake without noticing it during the development are low.

@cnotv
Copy link
Contributor Author

cnotv commented Sep 4, 2024

I was just thinking of a way to validate the solution in an automated way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vue3 Bugs and technical debts as outcome to the Vue3 migration kind/tech-debt Technical debt QA/None
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants