refactor(ui5-slider): slider handle and scale extraction#13033
refactor(ui5-slider): slider handle and scale extraction#13033
Conversation
|
🚀 Deployed on https://pr-13033--ui5-webcomponents-preview.netlify.app |
packages/main/src/SliderTemplate.tsx
Outdated
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
| } 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) |
There was a problem hiding this comment.
Could we somehow use a CSS var instead of hardcoded number, in case it changes depending on a theme or theme density?
There was a problem hiding this comment.
Lets leave such logic for the new responsive scale implementation
There was a problem hiding this comment.
- The accessibility part is broken - slider's value is not announced as well as how to increase or decrease the value.
- 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
- 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.
- 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.
- 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
- 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.
- 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
- In RTL mode, the end dot is placed at the beginning and has blue color.
| * | ||
| */ | ||
| onBeforeRendering() { | ||
| if (!this.isCurrentStateOutdated()) { |
There was a problem hiding this comment.
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", () => { |
There was a problem hiding this comment.
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.", () => { |
| * @formProperty | ||
| * @public | ||
| */ | ||
| @property({ type: Number }) |
There was a problem hiding this comment.
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.
packages/main/src/SliderHandle.ts
Outdated
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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() { | |||
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; | |||
There was a problem hiding this comment.
--_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); |
There was a problem hiding this comment.
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 { | |||
There was a problem hiding this comment.
Previously, the cursor was pointer, now it is not. Do you know which one is expected
| width: 100%; | ||
| position: relative; | ||
| background: var(--ui5_slider_scale_background); | ||
| border: var(--_ui5_slider_scale_border); |
There was a problem hiding this comment.
currently border results in 0.857rem instead of 1px.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); | ||
| } |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
No description provided.