Skip to content
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

fix(slider): incorrect updating to value #938

Merged
merged 5 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/elements/src/slider/__test__/slider.number-field.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,21 @@ describe('slider/NumberField', function () {
expect(inputFrom.readonly).to.equal(false);
expect(inputTo.readonly).to.equal(false);
});

it('Should increse "to" value via increase number-field value in range mode', async function () {
el.range = true;
el.showInputField = '';
el.to = '10';
await elementUpdated(el);

const inputTo = getNumberField(el, 'to');
setTimeout(() => inputTo.dispatchEvent(new Event('focus')));
await oneEvent(inputTo, 'focus');
inputTo.value = '20';
setTimeout(() => inputTo.dispatchEvent(new Event('blur')));
await oneEvent(inputTo, 'blur');

await elementUpdated(el);
expect(el.to).to.equal('20');
});
});
4 changes: 2 additions & 2 deletions packages/elements/src/slider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import type { NumberField } from '../number-field';
* @fires value-changed - Fired when the user commits a value change. The event is not triggered if `value` property is changed programmatically.
* @fires from-changed - Fired when the user changes from's value. The event is not triggered if `from` property is changed programmatically.
* @fires to-changed - Fired when the user changes to's value. The event is not triggered if `to` property is changed programmatically.
* @fires input - Fired when the user inputs a value by interacting with the slider or updating its input field.
* @fires input - Fired with the value of the input in `e.detail.value` like another custom events when the user inputs a value by interacting with the slider or updating its input field.
* @fires from-input - Fired when the user inputs from's value by interacting with the slider or updating its input field.
* @fires to-input - Fired when the user inputs to's value by interacting with the slider or updating its input field.
*/
Expand Down Expand Up @@ -1155,7 +1155,7 @@ export class Slider extends ControlElement {
if (this.range) {
if (valueFor === SliderDataName.to && value < this.fromNumber + this.minRangeNumber) {
return false;
} else if (value > this.toNumber - this.minRangeNumber) {
} else if (valueFor === SliderDataName.from && value > this.toNumber - this.minRangeNumber) {
return false;
}
}
Expand Down