Skip to content

refactor(ui5-slider): slider handle and scale extraction#13033

Open
MapTo0 wants to merge 2 commits intomainfrom
slider-refactoring-2
Open

refactor(ui5-slider): slider handle and scale extraction#13033
MapTo0 wants to merge 2 commits intomainfrom
slider-refactoring-2

Conversation

@MapTo0
Copy link
Contributor

@MapTo0 MapTo0 commented Feb 5, 2026

No description provided.

@MapTo0 MapTo0 changed the title refactor(ui5-slider): slider handle extraction refactor(ui5-slider): slider handle and scale extraction Feb 5, 2026
@MapTo0 MapTo0 requested review from ndeshev and niyap February 5, 2026 14:30
@ui5-webcomponents-bot
Copy link
Collaborator

ui5-webcomponents-bot commented Feb 5, 2026

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 5, 2026 14:38 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 9, 2026 08:53 Inactive
disabled={slider.disabled}
aria-orientation="horizontal"
part="handle-container"
aria-valuemin={slider.min}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there is no longer role="slider" accessibility attribute?

tabIndex={slider.disabled ? -1 : 0}
disabled={slider.disabled}
aria-orientation="horizontal"
part="handle-container"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the part name was just "handle". This will break the apps that already uses it.

}

get _tickmarksCount() {
return (this.max - this.min) / this.step;
Copy link
Contributor

@ndeshev ndeshev Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be good to return if step is 0 to avoid division by 0, in fact, setting the step property to 0 breaks the code in more than one place. in get _allTickmarks() the script throws an exception and at least my browser crashes. I think we should at least avoid uncaught exceptions in case of unwanted property values.

@property({ type: Number })
min = 0;

@property({ type: Number })
Copy link
Contributor

@ndeshev ndeshev Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document these props at least a little bit :) You've done it in SliderHandle.ts

this.storePropertyState("labelInterval");
}
_handleResize() {
// TODO: Remove after refactoring Base and RangeSlider
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

} else {
// Calculate if labels would overlap based on their estimated width
const visibleLabelCount = Math.ceil((tickmarksCount - 1) / this.labelInterval) + 1;
const estimatedLabelWidth = 32; // Estimated width in pixels for a label (2rem = ~32px)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we somehow use a CSS var instead of hardcoded number, in case it changes depending on a theme or theme density?

Copy link
Contributor

@niyap niyap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. The accessibility part is broken - slider's value is not announced as well as how to increase or decrease the value.
  2. Now, when an invalid value is set, it is not reset anymore. The problem is that that invalid value is set as value of aria-valuenow of the handle and end-value of the scale. If that change is desired, could you please check if it is appropriate from accessibility perspective
  3. According to the UX specification, the first and the last label should always be visible. In such case, what should happen, if you have the following situation: on the test page, slider with id="slider-tickmarks-labels" enhance with step="3" and label-interval="2" -> the last visible one is 16 as it is the last available in the predefined range. Should we visualised 20 at the end as the end of the interval or leave it without label as there is next valid one in out of range.
  4. Tooltips and inputs values are not updated correctly if you just click somewhere over a tickmark of the slider. Works as expected if you drag the handle.
  5. If you set min value greater than the max one, the slider is broken at all. Labels and tickmarks are not rendered. Handle cound not be dragged, tooltip is not updated and etc. Do you know what should we do in such case, I am not sure if it a valid one but if not, we can add some documentation/note about that
  6. In the documentation we state that if the step is equal to 0, slider handle movement is disabled. When negative number or value other than a number, the component fallbacks to its default value. -> currently if you set the step to 0, the slider is even not rendered and а console error is logged. Please, also check when the step value has been changed programmatically.
  7. If you have editable tooltip and you change its value to a invalid one -> value state is changed to error, then you update it again with a valid one and press Enter, the handle is moved to the correct point of the slider, the tooltip now shows a valid value, but the value state is not updated, still remains error. Even on focusout, if you hover over the handle, you will notice that it is still invalid
  8. In RTL mode, the end dot is placed at the beginning and has blue color.

*
*/
onBeforeRendering() {
if (!this.isCurrentStateOutdated()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, update the documentation as it describes the deleted logic.

cy.get("@slider").should("have.value", 1, "The current value should be 'stepified' by 7");
});

it("If the step property or the labelInterval are changed, the tickmarks and labels must be updated also", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it good to have such a test?

.and('have.length', 6);
});

it("If the min and max properties are changed, the tickmarks and labels must be updated also.", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants