-
Notifications
You must be signed in to change notification settings - Fork 106
Open
Labels
featureNew feature or requestNew feature or requestneeds: prioritizationTo be prioritizedTo be prioritizedpriority: lowSeverity level: 3Severity level: 3
Milestone
Description
Description of the requested feature
There is a randomId getter in pfelement.js.
https://github.com/patternfly/patternfly-elements/blob/master/elements/pfelement/src/pfelement.js#L168
I'd like to propose we create some utility files in that would export functions like creating a random ID that we could import into other components where needed. I'm picturing something along the lines of
function randomId(prefix = "", suffix = "") {
return `${prefix}${Math.random().toString(36).substr(2, 9)}${suffix}`;
}
export { randomId }
And then use it like this in a component like pfe-accordion.js
import { randomId } from "some-utility-file.js"
...
_id: {
type: String,
default: el => `${randomId(el.tag)}`,
prefix: false
}
...
The benefit of doing it this way is that we can remove the getter from pfelement.js since it's more of a utility function and then use it however we need to in any of the other components.
Impacted component(s)
- pfelement
- pfe-accordion
- pfe-primary-detail
- pfe-content-set
- pfe-jump-links
- pfe-modal
- pfe-tabs
Metadata
Metadata
Assignees
Labels
featureNew feature or requestNew feature or requestneeds: prioritizationTo be prioritizedTo be prioritizedpriority: lowSeverity level: 3Severity level: 3