File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
components/react/__tests__/__snapshots__ Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ exports[`ModalDialog renders correctly: portal 1`] = `
88 class = " modal modal-open fixed flex p-0 m-0 top-0 left-0 undefined"
99 data-headlessui-state = " open"
1010 data-open = " "
11- id = " headlessui-dialog-«r3m »"
11+ id = " headlessui-dialog-«normalized »"
1212 role = " dialog"
1313 style = " background-color: transparent; align-items: center; justify-content: center; height: 100vh; width: 100vw;"
1414 tabindex = " -1"
@@ -22,7 +22,7 @@ exports[`ModalDialog renders correctly: portal 1`] = `
2222 class = " undefined modal-box mx-auto rounded-[24px] bg-[#F4F4FF] dark:bg-[#1D192D] shadow-lg relative"
2323 data-headlessui-state = " open"
2424 data-open = " "
25- id = " headlessui-dialog-panel-«r3t »"
25+ id = " headlessui-dialog-panel-«normalized »"
2626 >
2727 bound HTMLFormElement {
2828 " 0" : <button
Original file line number Diff line number Diff line change 11import { format as prettyFormat , plugins as prettyFormatPlugins } from 'pretty-format' ;
22
33export function formatComponent ( value : any ) : string {
4- return prettyFormat ( value , {
4+ const formatted = prettyFormat ( value , {
55 escapeRegex : true ,
66 indent : 2 ,
77 plugins : [
@@ -14,4 +14,14 @@ export function formatComponent(value: any): string {
1414 ] ,
1515 printFunctionName : false ,
1616 } ) ;
17+
18+ // Normalize dynamic Headless UI IDs for consistent snapshots
19+ return formatted
20+ . replace ( / h e a d l e s s u i - d i a l o g - « r \w + » / g, 'headlessui-dialog-«normalized»' )
21+ . replace ( / h e a d l e s s u i - d i a l o g - p a n e l - « r \w + » / g, 'headlessui-dialog-panel-«normalized»' )
22+ . replace ( / h e a d l e s s u i - \w + - « r \w + » / g, match => {
23+ // Handle other headless UI components like headlessui-menu-«rXX», etc.
24+ const componentType = match . split ( '-' ) [ 1 ] ;
25+ return `headlessui-${ componentType } -«normalized»` ;
26+ } ) ;
1727}
You can’t perform that action at this time.
0 commit comments