New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(id) use universally unique ids for the id mixin (fixes #7004) #7021
base: dev
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 25cd124:
|
Codecov Report
@@ Coverage Diff @@
## dev #7021 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 299 299
Lines 10265 10270 +5
Branches 2527 2528 +1
=========================================
+ Hits 10265 10270 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Does anyone know why the CI pipeline has been stuck for >2 weeks? |
@stam thank you for your contribution! Having UUID seems a bit of overkill for me (that will be leeeeeengthy IDs). Also this will cause problems for tests which are using snapshots - because each time local id will be updated (yeah, we can solve it by writing smart serializer but I prefer not to break existing user experience unless really needed) I can suggest two approaches, both are fine for me:
Expose new method
Just making a global counter in the module, which autoincrements each time :)
beforeEach(() => setLocalIdInitialValue(0)); making all snapshot tests work reliably WDYT? |
This is BV3's implementation: /**
* @param suffix
* @returns
*/
export default (suffix = ''): string =>
`__BVID__${Math.random().toString().slice(2, 8)}___BV_${suffix}__` Generally, it's written as a composable to the same affect as the mixin you use. Six "random" numbers and a suffix seems good enough to prevent any possible overlaps. |
@VividLemon this is an approach I would like to avoid - it will generate totally new IDs on each run :) |
Seems like it would be desirable to avoid conflicts. |
Hey @xanf If you have snapshot test 1,2,3,4 & 5 and add test 2a, snapshot tests 3, 4 & 5 will break. I seriously doubt anyone is snapshot testing bootstrap-vue components without passing an id prop. |
Describe the PR
Make the id mixin use a universally unique id. Previously vue's internal id was used.
This is a locally unique id, but when there are multiple vue bundles on the same page it's not globally unique anymore. (#7004)
Because these ids are used to link labels to checkboxes or form elements, using local ids lead to some undefined behavior where checkboxes stopped working because they pointed to an id in use by another input element.
PR checklist
What kind of change does this PR introduce? (check at least one)
fix(...)
, requires a patch version updatefeat(...)
, requires a minor version updatefeat(...)
, requires a minor version updatefix(...)
, requires a patch or minor version updatechore(docs)
, requires a patch version updateDoes this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
dev
branch, not themaster
branch[...] (fixes #xxx[,#xxx])
, where "xxx" is the issue number)fix(alert): not alerting during SSR render
,docs(badge): update pill examples
,chore(docs): fix typo in README
, etc.). This is very important, as theCHANGELOG
is generated from these messages, and determines the next version type (patch or minor).If new features/enhancement/fixes are added or changed:
If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes: