Skip to content

Comments

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

Merged
MapTo0 merged 7 commits intomainfrom
slider-refactoring-2
Feb 25, 2026
Merged

refactor(ui5-slider): slider handle and scale extraction#13033
MapTo0 merged 7 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

🧹 Preview deployment cleaned up: https://pr-13033--ui5-webcomponents.netlify.app

@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
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.

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.

.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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

We agreed that it should be handled with the responsive scale implementaion

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 18, 2026 22:19 Inactive
@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 19, 2026 14:30 Inactive

cy.get<ColorPicker>("@colorPicker")
.should("have.value", "rgba(64, 191, 189, 1)");
.should("have.value", "rgba(64, 191, 191, 1)");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tsanislavgatev I believe this test used to be wrong? Could you please confirm? the Slider' value is now correct from 0 to 360, clicking center should count as value 180

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't say wrong, but testing on the current slider behaviour. Both colors are almost identical. They resolve to #40bfbf and #40bfbd which doesn't really have a noticable difference. The change in the test is okay, but I would say it just tests the behaviour of the component based on the behaviour of the slider.

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 19, 2026 14:49 Inactive
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. I found another accessibility issue:
    Previously, when an editable tootltip is presented and the slider handle receives focus, the announcement include: "Press F2 to enter a value", after the enhancements that information is not announced anymore.

  2. SliderBase.ts -> please update step property documentation, as it is written: "When negative number or value other than a number, the component fallbacks to its default value." which is not expected anymore. Check whether there is something similar for the other properties as well and if so, please remove it.

  3. Editable tooltip - delete its value -> focusout -> on hover over the handle it remains empty, on focus over the handle, still empty.

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.

We agreed that it should be handled with the responsive scale implementaion

@ui5-webcomponents-bot ui5-webcomponents-bot temporarily deployed to preview February 23, 2026 20:52 Inactive
@MapTo0 MapTo0 merged commit 056a123 into main Feb 25, 2026
14 checks passed
@MapTo0 MapTo0 deleted the slider-refactoring-2 branch February 25, 2026 15:02
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.

6 participants