-
Notifications
You must be signed in to change notification settings - Fork 375
Description
Problem
Components that use the randomly generated IDs can have duplicate IDs, if a multiple versions of PF are loaded into the browser. A typical example is an environment that uses module federation.
How do you reproduce the problem?
Create a module federation environment, with 2 modules that share @patternfly/react-core using different versions so the modules do not meet the version range requirements.
Use some components that use the GenerateId wrapper. There will be duplicate IDs
Expected behavior
Each ID will be unique.
Is this issue blocking you?
Causes some bugs in HCC
Possible fixes
-
Make the sequence global by storing the current sequence value in the
globalThis:patternfly-react/packages/patternfly-4/react-core/src/internal/GenerateId/GenerateId.js
Line 21 in 159798e
let currentId = 0; -
Add some random string to the prefix so each module instance has a unique prefix:
something likepatternfly-react/packages/patternfly-4/react-core/src/internal/GenerateId/GenerateId.js
Line 32 in 159798e
prefix: 'pf-random-id-' pf-random-id-111-
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
