Skip to content

TimePicker should vertically centre the selected values #480

@aidanlister

Description

@aidanlister

This makes the time picker behave more like the iOS time picker.

Time picked:
Image

Custom number entered:
Image

--- a/dist/esm/components/time-picker/CTimePickerRollCol.js
+++ b/dist/esm/components/time-picker/CTimePickerRollCol.js
@@ -17,14 +17,14 @@ var CTimePickerRollCol = forwardRef(function (_a, ref) {
         var nodeEl = (_a = colRef.current) === null || _a === void 0 ? void 0 : _a.querySelector('.selected');
         if (isVisible && nodeEl && nodeEl instanceof HTMLElement) {
             (_b = colRef.current) === null || _b === void 0 ? void 0 : _b.scrollTo({
-                top: nodeEl.offsetTop,
+                top: nodeEl.offsetTop - nodeEl.offsetHeight * 3.5,
                 behavior: init.current ? 'auto' : 'smooth',
             });
         }
         if (isVisible) {
             init.current = false;
         }
-    }, [isVisible, selected]);
+    }, [isVisible, selected, elements]);
     var handleKeyDown = function (event, value) {
         if (event.code === 'Space' || event.key === 'Enter') {
             event.preventDefault();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions