Skip to content

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

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

refactor(ui5-slider): slider handle and scale extraction#13033
MapTo0 wants to merge 3 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
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a check but still, application setting step 0 is problem in the application, guarding this would cover potential application bugs.

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 Author

Choose a reason for hiding this comment

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

Lets leave such logic for the new responsive scale implementation

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

* @formProperty
* @public
*/
@property({ type: Number })
Copy link
Contributor

Choose a reason for hiding this comment

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

If we have negative value both for min and max, for example min="-20" and max="-10" and we do not define value. Value is 0 by default which is out of the range, if we have tooltip, it also shows 0 (the default value)(even not marked as invalid value of the range initially.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need it and use it somewhere, as I noticed that _handlePosition with the same logic is implemented and used in SliderTemplate

const visibleLabelCount = Math.ceil((tickmarksCount - 1) / this.labelInterval) + 1;
const estimatedLabelWidth = 32; // Estimated width in pixels for a label (2rem = ~32px)
const requiredWidth = visibleLabelCount * estimatedLabelWidth;
this._labelsOverlapping = containerSize < requiredWidth;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you have a slider with labels and tickmarks and you update the step programmatically, the labels are not rendered correctly. The last one is not visualised where it should always be. I tested on "Slider with steps, input tooltips, tickmarks and labels" sample, changing the step value on change

@@ -263,7 +232,7 @@

_onTooltipOpen() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the sample with the float values. Initially on hover, the tooltip shows the value with the two decimals places precision but if you click couple times over the handle (without changing the value), the tooltip value is shown just 10.

}

:host([label-interval]:not([label-interval="0"])) {
height: 3.75rem;
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 that hight expected when we have tooltips, not labels.

@@ -0,0 +1,11 @@
:host {
--_slider_root_side_padding: 0 1rem;
--_slider_height: 2.75rem;
Copy link
Contributor

Choose a reason for hiding this comment

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

--_slider_height that variable is defined only for Horizon Light theme, in all other supported theme it resolves to undefined

height: 100%;
display: flex;
align-items: center;
padding: var(--_slider_root_side_padding);
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, there was a padding in all supported themes, now you define value only for the Horizon Light and Dark. Is there a reason?

@@ -0,0 +1,148 @@
:host {
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 cursor was pointer, now it is not. Do you know which one is expected

Copy link
Contributor

Choose a reason for hiding this comment

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

redundant empty line

width: 100%;
position: relative;
background: var(--ui5_slider_scale_background);
border: var(--_ui5_slider_scale_border);
Copy link
Contributor

Choose a reason for hiding this comment

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

currently border results in 0.857rem instead of 1px.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is redundant, on the next line you define the same variable but with value none which I think is the expected one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is redundant, on the next line you define the same variable but with value none which I think is the expected one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is redundant, on the next line you define the same variable but with value none which I think is the expected one.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that is redundant, on the next line you define the same variable but with value none which I think is the expected one.

top: 50%;
transform: translateY(-50%);
display: var(--_ui5_slider_scale_dots_display);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not find information about the offset between the scale and the dot, but I think it is bigger then that shown on the screenshots and a little bigger than it was before the change

@import "../base/SliderHandle-parameters.css";

:host {
--ui5_slider_handle_outline_offset: 3px;
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure is that the correct value here, as I did not find it specified anywhere. In the documentation, it is mentioned that the offset is 1px but on the other hand, if we look at the screenshots, it looks bigger. Do you know the reason to be 3px? The sam is valid for HCW as well

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 18, 2026 22:19 Inactive
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

Comments