[Bug]: Button shims in react-migration-v8-v9 always render the ms-Button--primary class
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
Leggi packages/react/src/components/Button ed esamina shimButtonProps.tsx e le assegnazioni delle varianti dello shim del pulsante. Inizia verificando come variantClassName e primary determinano la classe v8 renderizzata, compreso il caso toggle. Aggiorna i test pertinenti o aggiungi copertura per ogni shim, quindi conferma che gli shim default, action, compound, primary e toggle renderizzino le classi previste.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Component
Migration Shims V8
Package version
@fluentui/[email protected] (the current release)
React version
18.3.1
Environment
System:
OS: Windows 11 10.0.26300
CPU: (24) x64 AMD Ryzen 9 7900X 12-Core Processor
Memory: 12.92 GB / 31.16 GB
Browsers:
Chrome: 156.0.8078.47
npmPackages (reproduction page, loaded from esm.sh):
@fluentui/react-migration-v8-v9: 9.10.22
react: 18.3.1
react-dom: 18.3.1
Current Behavior
Every Button shim renders the v8 variant class ms-Button--primary, whichever v8 button it shims. Apps that kept styles or test selectors written against the v8 class names (ms-Button--default, ms-Button--action, ms-Button--compound, and so on) stop matching after moving to the shims.
shimButtonProps.tsx builds the class with:
const variantClassName = props.variantClassName ?? props.primary ? 'ms-Button--primary' : 'ms-Button--default';
That parses as (props.variantClassName ?? props.primary) ? 'ms-Button--primary' : 'ms-Button--default'. Every shim passes a variantClassName (DefaultButtonShim, ActionButtonShim, CompoundButtonShim, MenuButtonShim, ...), so the condition is always truthy and the explicit class is replaced by ms-Button--primary.
Measured with the reproduction below on 9.10.22:
| Shim | v8 class | Shim class |
|---|---|---|
| DefaultButtonShim | ms-Button--default |
ms-Button--primary |
| ActionButtonShim / CommandButtonShim | ms-Button--action ms-Button--command |
ms-Button--primary |
| CompoundButtonShim | ms-Button--compound |
ms-Button--primary |
CompoundButtonShim primary |
ms-Button--compoundPrimary |
ms-Button--primary |
| MenuButtonShim | ms-Button--default |
ms-Button--primary |
DefaultButtonShim toggle |
ms-Button--default |
ms-Button--primary |
Only the primary variants happen to come out right. The v9 appearance is not affected, because it is driven by primary separately; only the v8 class names are wrong.
ToggleButtonShim also sets ms-Button--compound / ms-Button--compoundPrimary, which looks copied from CompoundButtonShim. v8 has no toggle variant class (toggle is a prop on the v8 buttons), so with the precedence fixed alone, a toggled DefaultButtonShim would render ms-Button--compound.
Expected Behavior
Each shim renders the same variant class as the v8 button it replaces, as set in packages/react/src/components/Button:
DefaultButton:ms-Button--default, orms-Button--primarywhenprimaryActionButton/CommandButton:ms-Button--action ms-Button--commandCompoundButton:ms-Button--compound, orms-Button--compoundPrimarywhenprimary- a toggle keeps the class of the button it is (for example
ms-Button--defaultfor a toggledDefaultButton)
Reproduction
https://gist.github.com/jakesalvesen/6b22523f25863eda07652e87536d7355 - a standalone HTML page that loads @fluentui/[email protected] from esm.sh, renders each Button shim, and prints its ms-Button--* classes next to the v8 class.
Steps to reproduce
- Save the gist page and open it in a browser (no build step needed).
- The page renders
DefaultButtonShim,PrimaryButtonShim,ActionButtonShim,CommandButtonShim,CompoundButtonShim,MenuButtonShimand a toggledDefaultButtonShim, then prints a table. - 7 of the 9 rows show
ms-Button--primarywhere v8 renders a different class. - Parenthesizing the fallback,
props.variantClassName ?? (props.primary ? 'ms-Button--primary' : 'ms-Button--default'), makes every non-toggle row match.
Are you reporting an Accessibility issue?
no
Suggested severity
Low - Has or doesn't need a workaround
Products/sites affected
No response
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.
- Lingua principale
- TypeScript
- Stelle
- 20.3k
- Fork
- 2.9k
- Merge medio
- 2g 9h
- PR unite (30g)
- 67
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/fluentui
-
[Bug]: AreaChart renders SVG rect with negative width and height on initial renderForse già presa @huong8373tt-beep l’ha presa 2 giorni fa. ApertaNeeds: Triage :mag: Package: charting Type: Bug :bug:
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Vertical Slider still logs the deprecated 'slider-vertical' warning in Chromium 132+Forse già presa @jakesalvesen l’ha presa 4 giorni fa. ApertaFluent UI react-components (v9) Needs: Triage :mag: Type: Bug :bug:
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
microsoft/fluentui#36945 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
@fluentui/web-components: fluent-menu-list loses its arrow keys after it is moved in the DOM (Firefox, Safari)Forse già presa @asxxb l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/fluentui
Issue simili
-
area:desktop bug documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
anthropics/claude-code#104801 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: Halloween Non Stop SDApertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
spudly/design-system#110 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: REST API URL starting with "http" but no scheme (e.g. httpbin.org/get) is not given an http:// prefixForse già presa @ItsDeadlyProgrammer l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
appsmithorg/appsmith#42471 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni