[Bug]: fluent-checkbox submits "on" when the checked attribute is before value
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
Línea de trabajo
Empieza rastreando initialValueChanged e initialCheckedChanged en los componentes de checkbox y switch; el issue muestra que cambiar value después de checked hace que el valor enviado en el formulario quede desactualizado. Reproduce ambos órdenes de atributos y compara sus datos de formulario con los de un checkbox nativo. El trabajo estará terminado cuando ambos componentes Fluent envíen el valor declarado independientemente del orden de los atributos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Component
Checkbox
Package version
3.1.3
@microsoft/fast-element version
3.0.4
Environment
OS: Windows 11
Browsers: Microsoft Edge 155 (Chromium 155)
npmPackages:
@fluentui/web-components: 3.1.3
@microsoft/fast-element: 3.0.4
Current Behavior
When <fluent-checkbox> (or <fluent-switch>) is rendered with the checked attribute before the value attribute, checkbox.value returns the value attribute, but the form submits "on".
Attributes are applied in markup order during the upgrade:
checked→initialCheckedChanged→checked = true→setFormValue(this.value)with the default value"on".value→initialValueChangedonly sets_value, so the form value stays"on":
initialValueChanged(prev, next) {
this._value = next;
}
With value before checked, the expected value is submitted.
Expected Behavior
The attribute order doesn't matter: a checked <fluent-checkbox checked value="yes"> submits "yes", like <input type="checkbox" checked value="yes">.
Reproduction
https://oonoobmasteroo.github.io/fluent-checkbox-form-value/ (source: https://github.com/oONoobMasterOo/fluent-checkbox-form-value)
Steps to reproduce
- Open the reproduction:
<form id="form">
<fluent-checkbox name="checkedFirst" checked value="yes"></fluent-checkbox>
<fluent-checkbox name="valueFirst" value="yes" checked></fluent-checkbox>
<fluent-switch name="switchCheckedFirst" checked value="yes"></fluent-switch>
<input name="native" type="checkbox" checked value="yes">
<button type="button" id="check">Show FormData</button>
</form>
<pre id="out"></pre>
<script type="module">
import "https://cdn.jsdelivr.net/npm/@fluentui/[email protected]/dist/web-components.min.js";
document.getElementById("check").addEventListener("click", () => {
const data = Object.fromEntries(new FormData(document.getElementById("form")));
document.getElementById("out").textContent = JSON.stringify(data, null, 2);
});
</script>
- Click Show FormData.
- Result:
{ "checkedFirst": "on", "valueFirst": "yes", "switchCheckedFirst": "on", "native": "yes" }.
A possible fix: in initialValueChanged, also update the form value when the checkbox is checked (e.g. if (this.checked) this.setFormValue(next)).
Are you reporting an Accessibility issue?
no
Suggested severity
Medium - Has workaround
Products/sites affected
Fluent UI Blazor (FluentCheckbox / FluentSwitch in statically rendered forms; worked around by rendering value before checked)
Are you willing to submit a PR to fix?
yes
Validations
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- The provided reproduction is a minimal reproducible example of the bug.
- Lenguaje dominante
- TypeScript
- Estrellas
- 20.3k
- Forks
- 2.9k
- Merge medio
- 2 d 6 h
- PR fusionados (30 d)
- 53
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Sin guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/fluentui
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
[Docs]: Customizing components with slots - bad urlPosiblemente ocupada @Avanti-27 la tomó hace 3 días. AbiertoArea: Documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
microsoft/fluentui#36903 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
@fluentui/web-components: fluent-menu-list loses its arrow keys after it is moved in the DOM (Firefox, Safari)Posiblemente ocupada @asxxb la tomó hace 7 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
[Feature]: export getHashCode for Avatar from avatar.ts for Fluentv8 PersonaInitialsColor / PersonaCoin supportPosiblemente ocupada @ValentinaKozlova la tomó hace 20 días. AbiertoComponent: Avatar Fluent UI react-components (v9) From Shield Needs: Backlog review Type: Feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/fluentui#36802 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
[Bug]: WeeklyDayPicker showing incorrect week number when navigating to different weeksPosiblemente ocupada @Sanjays2402 la tomó hace 38 días. AbiertoComponent: CalendarDayGrid Component: WeeklyDayPicker Fluent UI react (v8) Type: Bug :bug:
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/fluentui#36721 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/fluentui
Issues similares
-
docs(api): openapi.yaml still documents gif-tools optimize colors as 2-256 instead of 2, 4, 16, 256Abiertoarea: backend documentation priority: low
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
snapotter-hq/SnapOtter#2919 ·
Los mantenedores suelen responder en 1 día
-
BUG: Uncaught MEMORY USAGE error on Redis < 4.0 causes keys table data load to fail entirelyAbiertoaccepted :+1: bug db/redis
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
beekeeper-studio/beekeeper-studio#4882 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
ready-for-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
konflux-ci/konflux-ui#1630 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
ahmedkhaleel2004/gitdiagram#233 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
simkimsia/netlify-axi#19 ·
Los mantenedores suelen responder en 1 día