Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/main/src/ComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import "./ComboBoxItemGroup.js";
// eslint-disable-next-line
import { isInstanceOfComboBoxItemGroup } from "./ComboBoxItemGroup.js";
import type ComboBoxFilter from "./types/ComboBoxFilter.js";
import type PopoverHorizontalAlign from "./types/PopoverHorizontalAlign.js";
import type Input from "./Input.js";
import type { InputEventDetail } from "./Input.js";
import type { ListItemBaseClickEventDetail } from "./ListItemBase.js";
Expand Down Expand Up @@ -401,6 +402,15 @@ class ComboBox extends UI5Element implements IFormInputElement {
@property({ type: Boolean })
showClearIcon = false;

/**
* Determines the horizontal alignment of the component's dropdown menu relative to the component.
* @default "Start"
* @public
* @since 2.26.0
*/
@property()
horizontalAlign: `${PopoverHorizontalAlign}` = "Start";

/**
* Indicates whether the input is focused
* @private
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/ComboBoxPopoverTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function ComboBoxPopoverTemplate(this: ComboBox) {
preventFocusRestore={true}
preventInitialFocus={true}
placement="Bottom"
horizontalAlign="Start"
horizontalAlign={this.horizontalAlign}
accessibleName={this._popupLabel}
onBeforeOpen={this._beforeOpenPopover}
onOpen={this._afterOpenPopover}
Expand Down
66 changes: 66 additions & 0 deletions packages/main/test/pages/ComboBox.html
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,72 @@ <h3>Newline Normalization Test</h3>
</script>
</div>

<div class="demo-section" style="padding: 30px; background: #f5f5f5; border: 3px solid #0854a0; border-radius: 8px; margin: 20px 0;">
<h3 style="color: #0854a0; margin-top: 0;">Horizontal Align Property</h3>
<p>Control the horizontal alignment of the dropdown menu relative to the ComboBox.</p>
<br />

<div style="display: flex; justify-content: space-between; gap: 20px; margin-bottom: 40px;">
<div style="flex: 1;">
<ui5-label>Start (default) - Left side:</ui5-label>
<br />
<ui5-combobox id="align-start" horizontal-align="Start" style="width: 200px;">
<ui5-cb-item text="Algeria"></ui5-cb-item>
<ui5-cb-item text="Argentina"></ui5-cb-item>
<ui5-cb-item text="Australia"></ui5-cb-item>
<ui5-cb-item text="Very long text that makes popover wider than the ComboBox"></ui5-cb-item>
<ui5-cb-item text="Austria"></ui5-cb-item>
<ui5-cb-item text="Bahrain"></ui5-cb-item>
<ui5-cb-item text="Belgium"></ui5-cb-item>
</ui5-combobox>
</div>

<div style="flex: 1; display: flex; flex-direction: column; align-items: center;">
<ui5-label>Center - Middle:</ui5-label>
<br />
<ui5-combobox id="align-center" horizontal-align="Center" style="width: 200px;">
<ui5-cb-item text="Algeria"></ui5-cb-item>
<ui5-cb-item text="Argentina"></ui5-cb-item>
<ui5-cb-item text="Australia"></ui5-cb-item>
<ui5-cb-item text="Very long text that makes popover wider than the ComboBox"></ui5-cb-item>
<ui5-cb-item text="Austria"></ui5-cb-item>
<ui5-cb-item text="Bahrain"></ui5-cb-item>
<ui5-cb-item text="Belgium"></ui5-cb-item>
</ui5-combobox>
</div>

<div style="flex: 1; display: flex; flex-direction: column; align-items: flex-end;">
<ui5-label>End - Right side:</ui5-label>
<br />
<ui5-combobox id="align-end" horizontal-align="End" style="width: 200px;">
<ui5-cb-item text="Algeria"></ui5-cb-item>
<ui5-cb-item text="Argentina"></ui5-cb-item>
<ui5-cb-item text="Australia"></ui5-cb-item>
<ui5-cb-item text="Very long text that makes popover wider than the ComboBox"></ui5-cb-item>
<ui5-cb-item text="Austria"></ui5-cb-item>
<ui5-cb-item text="Bahrain"></ui5-cb-item>
<ui5-cb-item text="Belgium"></ui5-cb-item>
</ui5-combobox>
</div>
</div>

<div style="display: flex; justify-content: center;">
<div>
<ui5-label>Stretch - Matches ComboBox width:</ui5-label>
<br />
<ui5-combobox id="align-stretch" horizontal-align="Stretch" style="width: 200px;">
<ui5-cb-item text="Algeria"></ui5-cb-item>
<ui5-cb-item text="Argentina"></ui5-cb-item>
<ui5-cb-item text="Australia"></ui5-cb-item>
<ui5-cb-item text="Very long text that makes popover wider than the ComboBox"></ui5-cb-item>
<ui5-cb-item text="Austria"></ui5-cb-item>
<ui5-cb-item text="Bahrain"></ui5-cb-item>
<ui5-cb-item text="Belgium"></ui5-cb-item>
</ui5-combobox>
</div>
</div>
</div>

</body>

</html>
Loading