Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TimeItem (useTextField="false") does not account for SelectItem CSS padding when calculating width

    I have overridden the default styles for input controls and, so far, have not encountered any rendering issues except with TimeItem when useTextField="false" is used.
    With my custom styles applied, the component is rendered incorrectly (see screenshot below).

    Click image for larger version  Name:	Screenshot 2026-06-18 121456.jpeg Views:	0 Size:	6.3 KB ID:	277637

    After reviewing the source code, I found that the width of the internal SelectItem controls is calculated in the code section shown below. The calculation does not appear to take into account the additional space introduced by the custom CSS styles.

    Custom CSS
    Code:
    .selectItemControl,
    .selectItemControlOver,
    .selectItemControlDisabled,
    .selectItemControlError,
    .selectItemControlErrorOver,
    .selectItemControlFocused,
    .selectItemControlFocusedOver
    {
      border: var(--border);
      border-radius: 4px;
      padding-left: 8px;
      padding-right: 2px;
    }
    .selectItemText,
    .selectItemTextOver,
    .selectItemTextDown,
    .selectItemTextError,
    .selectItemTextErrorOver,
    .selectItemTextFocused,
    .selectItemTextFocusedOver,
    .selectItemTextDisabled,
    .selectItemTextHint,
    .selectItemTextDisabledHint,
    .comboBoxItemPendingText {
      border: 0;
      padding: 0px;
    }
    Current implementation in isc.TimeItem.setItems()
    Code:
    var baseStyleName = isc.SelectItem.getInstanceProperty("textBoxStyle"),
                    // get the extra width to add to the render-width of the widest valueMap entry
                    extraWidth = isc.SelectItem.getInstanceProperty("pickerIconWidth") +
                        isc.Element._getLeftMargin(baseStyleName) +
                        isc.Element._getRightMargin(baseStyleName) +
                        isc.Element._getHBorderPad(baseStyleName) +
                        4 // this last is necessary because there is no right-padding
                ;
    Question
    Would it be possible to replace this code with a version that takes the padding defined in controlStyle into account?
    I tested the following modification locally and it appears to work correctly:
    Code:
                var baseStyleName = isc.SelectItem.getInstanceProperty("controlStyle"),
                    textBaseStyleName = isc.SelectItem.getInstanceProperty("textBoxStyle"),
                    rightPadding = isc.Element._getRightPadding(baseStyleName) ? 0 : 4;
                    // get the extra width to add to the render-width of the widest valueMap entry
                    extraWidth = isc.SelectItem.getInstanceProperty("pickerIconWidth") +
                        isc.Element._getHBorderPad(baseStyleName) +
                        isc.Element._getLeftMargin(textBaseStyleName) +
                        isc.Element._getRightMargin(textBaseStyleName) +
                        isc.Element._getHBorderPad(textBaseStyleName) +
                        rightPadding // this last is necessary because there is no right-padding
                ;

    I also noticed a related issue with the PickList width.
    When clicking any of the three SelectItems within the TimeItem for the first time, the PickList is displayed with an incorrect width.
    After closing and opening the same PickList again, its width is calculated correctly and the PickList is displayed as expected.
    This behavior suggests that the initial width calculation may not be taking all style-related dimensions into account, while subsequent openings use an updated or recalculated width.
    Click image for larger version  Name:	Screenshot 2026-06-18 122214.jpeg Views:	0 Size:	5.5 KB ID:	277638

    Click image for larger version  Name:	Screenshot 2026-06-18 122304.jpeg Views:	0 Size:	4.6 KB ID:	277639
    Last edited by Hirn; Today, 02:28.

    #2
    I noticed that this code is sufficient to fix the issue.
    Code:
                var baseStyleName = isc.SelectItem.getInstanceProperty("controlStyle"),
                    textBaseStyleName = isc.SelectItem.getInstanceProperty("textBoxStyle"),
                    rightPadding = isc.Element._getRightPadding(baseStyleName) || 0;
                    rightPadding += 4;
                    // get the extra width to add to the render-width of the widest valueMap entry
                    extraWidth = isc.SelectItem.getInstanceProperty("pickerIconWidth") +
                        isc.Element._getLeftMargin(textBaseStyleName) +
                        isc.Element._getRightMargin(textBaseStyleName) +
                        isc.Element._getHBorderPad(textBaseStyleName) +
                        rightPadding // this last is necessary because there is no right-padding
                ;
    With this code, the component actually looks even better than with my initially suggested version.

    Comment

    Working...
    X