feat(chore): Unique ids. - OEL-3642#663
Conversation
|
🚀 Deployed on https://preview-663--oelibrary.netlify.app |
| #} | ||
|
|
||
| {% set _id = id|default('dropdown-' ~ random(1000)) %} | ||
| {% set _id = id|default('dropdown-' ~ random(10000) ~ "-" ~ "now"|date('u')) %} |
There was a problem hiding this comment.
I was going to suggest the use of a Drupal core filter like this: https://www.drupal.org/node/3363551
But the library itself is not tied to Drupal so we cannot rely on that filter.
A probability of 0.0001 should be enough.
An improvement could be to pass the correct values on the templates where this is used.
Remember to update comment above with parameters.
There was a problem hiding this comment.
"I was going to suggest the use of a Drupal core filter like this: https://www.drupal.org/node/3363551
But the library itself is not tied to Drupal so we cannot rely on that filter2
This is already commented in the issue #642 and can't really be done without third party libraries
"A probability of 0.0001 should be enough.
An improvement could be to pass the correct values on the templates where this is used."
We also added microtime to the id, I tested adding several dropdowns to the preview content in the same example and the microtimes of each one is different
I updated the doc
There was a problem hiding this comment.
Ideally oe_bootstrap_theme would use the dropdown passing the correct id based on an unique filter.
The component itself is not aware of other possible dropdowns.
You can play with probabilities, but the only safe mode of doing this is excluding used ids.
|
redone this on a different branch because it was needed to add #default# at the end of the branch for netlify deploy only on the default theme. |
Extend random range and add microtime to id generation.
Fix for issue #642