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

Checkbox and InputSwitch: "on" CSS classes not applied #5454

Closed
vzakharov opened this issue Mar 21, 2024 · 1 comment
Closed

Checkbox and InputSwitch: "on" CSS classes not applied #5454

vzakharov opened this issue Mar 21, 2024 · 1 comment

Comments

@vzakharov
Copy link

vzakharov commented Mar 21, 2024

Describe the bug

Don’t know what update initially caused the fault, but in 3.50.0 p-inputswitch-checked is not applied to InputSwitches, and p-highlight is not applied to Checkboxes’ boxes (but it is applied to the main class, which doesn’t cause anything, and where the bug probably is).

Here are workaround components that I have to use rn:

For the checkbox:

<template>
  <Checkbox :="$attrs"
    :pt="{ box: { class: { 'p-highlight': checked } } }"
  />
</template>

<script setup lang="ts">
import Checkbox from 'primevue/checkbox';
import { computed, useAttrs } from 'vue';
const attrs = useAttrs() as {
  binary: true,
  modelValue: boolean,
  value: never,
} | {
  binary: undefined,
  modelValue: string[],
  value: string,
};

const checked = computed(() => 
  attrs.binary !== undefined 
    ? attrs.modelValue 
    : attrs.modelValue.includes(attrs.value)
  );
</script>

(not that this is a very simplified approach that does not support trueValues/falseValues.)

For the input switch:

<template>
  <InputSwitch :="$attrs"
    :class="{ 'p-inputswitch-checked': $attrs.modelValue }"
  />
</template>

<script setup lang="ts">
import InputSwitch from 'primevue/inputswitch';
</script>

Hopefully this gets fixed at some point so I can get back to using original components.

P.S. Sorry I won’t spend time creating a reproducer. I’m hoping, if other people are facing the same issue, this workaround will help them. If not, you can just ignore the ticket.

Reproducer

https://sorry-i-wont

PrimeVue version

3.50.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@vzakharov vzakharov added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Mar 21, 2024
@tugcekucukoglu
Copy link
Member

There have been major changes since v3.47.0. Reference issue: #5071

@tugcekucukoglu tugcekucukoglu removed the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants