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
[Bug]: sp-slider only adds one sp-slider-handle when multiple are defined #2035
Comments
|
@peterjanes thanks for sharing this issue! Before we can fully review changes in support of what you're experiencing, we will need a reproduction case so that we can compare your findings with ours and ensure that all users of this element are being appropriately served. I'd suggest you start from something like https://webcomponents.dev/edit/collection/fO75441E1Q5ZlI0e9pgq/U7LQv7LsAVBwJayJXG3B/src/index.ts and see if you can isolate the issue you are experiencing. |
|
Yeah, I've been working on a reproduce case for a couple of days but can't get it to fail. Figured I'd submit the PR that fixes it (or appears to) as it seems like a pretty obvious update; |
|
Here's my current non-failing reproduce case, which mirrors what the live code does: <!DOCTYPE html>
<script src="https://jspm.dev/@spectrum-web-components/bundle/elements.js" type="module"></script>
<div>
<sp-theme scale="medium" color="light">
</sp-theme>
</div>
<template id="rangeTemplate">
<sp-slider variant="range" step="1">
<sp-slider-handle slot="handle" name="min" label="Minimum" max="next"></sp-slider-handle>
<sp-slider-handle slot="handle" name="max" label="Maximum" min="previous"></sp-slider-handle>
</sp-slider>
</template>
<script module>
async function foo() {
const res = await fetch('.');
const rangeGroups = new Map();
rangeGroups.set('group1', [{id: 'range1.1', min: 10, max: 90}, {id: 'range1.2', min: 15, max: 85}]);
rangeGroups.set('group2', [{id: 'range2.1', min: 20, max: 80}, {id: 'range2.2', min: 25, max: 75}]);
const rangesList = document.createElement('div');
const rangeTemplate = document.querySelector('#rangeTemplate');
rangeGroups.forEach((rangeGroup, key) => {
const rangeList = document.createElement('div');
rangeGroup.forEach((range) => {
const rangeElement = rangeTemplate.content.cloneNode(true);
const slider = rangeElement.querySelector('sp-slider');
slider.setAttribute('id', range.id);
slider.setAttribute('label', range.id);
slider.setAttribute('min', String(range.min));
slider.setAttribute('max', String(range.max));
slider.querySelector('[name=min]').setAttribute('value', String(range.min));
slider.querySelector('[name=max]').setAttribute('value', String(range.max));
rangeList.appendChild(rangeElement);
});
rangesList.appendChild(rangeList);
});
document.querySelector('sp-theme').appendChild(rangesList);
return 'done';
}
foo().then(console.log);
</script> |
|
I assume you're not using |
|
In the live app I've reduced that whole thing to function createElement(html) {
const temp = document.createElement('template');
temp.innerHTML = html.trim();
return temp.content.firstChild;
}
async function foo() {
await fetch('.');
document.body.appendChild(
createElement(`<div>
<sp-slider variant="range" step="1" id="price" name="price" label="Max Price" min="35425" max="86610">
<sp-slider-handle slot="handle" name="min" label="Minimum" max="next" value="35425"></sp-slider-handle>
<sp-slider-handle slot="handle" name="max" label="Maximum" min="previous" value="86610"></sp-slider-handle>
</sp-slider>
</div>`);
}
foo();and it still fails. The app loads the dependencies with from |
|
How is JS loaded into the app? For instance this (working demo from above) uses |
|
|
I'm going to try again to strip down the app to something I can share instead of trying to build up a test case. Will let you know. |
|
https://home.peterjanes.ca/~peterj/2022/bug-2035/ has a fairly minimal failing test case, with no recompilation, subsetting, etc. of the Spectrum components. |
|
Thanks for the minimal example @peterjanes - I've used it to add a test reproducing the issue so that we can figure out a root cause. |
Code of conduct
Impacted component(s)
sp-slider, sp-slider-handle
Expected behavior
Adding an
sp-sliderwith multiple handles from an HTMLtemplateshould add all of the handles.Actual behavior
I haven't nailed down the exact conditions, but sometimes when adding
sp-sliders dynamically from an HTMLtemplateonly one instance ofsp-slider-handlewill be added because the handle map key isundefined. (I finally tracked down the behaviour when I started getting "First slider handle cannot have attribute min='previous'" after addingmax="next"to the firstsp-slider-handleandmin="previous"to the second.)Screenshots
No response
What browsers are you seeing the problem in?
Firefox, Chrome
How can we reproduce this issue?
I haven't been able to come up with a reduced test case, but the issue is 100% reproducible in my (currently non-public) app and seems to be due to some instances of a field not being renamed. (
handle.nameis used instead ofhandle.handleNameinHandleController.ts.) I'll create an associated pull request for review.Sample code that illustrates the problem
No response
Logs taken while reproducing problem
No response
The text was updated successfully, but these errors were encountered: