-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kb(Dropdowns): Add KB for disabled text wrapping #2855
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
title: DropDown Items Wrap or Overlap | ||
description: Learn how to resolve and prevent text wrapping of long items in Telerik Blazor dropdown components, such as AutoComplete, ComboBox, DropDownList, and MultiSelect. | ||
type: troubleshooting | ||
page_title: How to Prevent Dropdown Item Text Wrapping | ||
slug: dropdowns-kb-disable-long-text-wrap | ||
tags: blazor, autocomplete, combobox, dropdownlist, multiselect, css, styling | ||
ticketid: 1663555, 1668373, 1679799, 1682531 | ||
res_type: kb | ||
--- | ||
|
||
## Environment | ||
|
||
<table> | ||
<tbody> | ||
<tr> | ||
<td>Product</td> | ||
<td> | ||
AutoComplete for Blazor, <br /> | ||
ComboBox for Blazor, <br /> | ||
DropDownList for Blazor, <br /> | ||
MultiSelect for Blazor | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
## Description | ||
|
||
This KB article deals with the following scenarios: | ||
|
||
1. The items in a Telerik dropdown component are long and wrap to multiple lines. The items become very high. How to avoid and disable this behavior? | ||
1. A Telerik dropdown component is using virtualization with `ItemHeight`. Long items wrap and overlap. How to fix this UI issue? | ||
|
||
## Cause | ||
|
||
By default, the dropdown items are as wide as the dropdown. Text wrapping of longer items is expected. | ||
|
||
## Solution | ||
|
||
1. Set a custom class in the component's `PopupSettings`. | ||
1. Apply a `white-space: nowrap;` style to the custom class. | ||
1. If a `PopupSettings` tag was not present until this point, also set a `Height`, otherwise it will change from `"200px"` to `"auto"`. | ||
|
||
>caption Disable text wrapping and overlapping of long dropdown items | ||
|
||
````RAZOR | ||
<TelerikDropDownList Data="@ListItems" | ||
@bind-Value="@SelectedValue" | ||
TextField="@nameof(ListItem.Text)" | ||
ValueField="@nameof(ListItem.Id)" | ||
Width="160px"> | ||
<DropDownListSettings> | ||
<DropDownButtonPopupSettings Class="no-wrap" Height="200px" /> | ||
</DropDownListSettings> | ||
</TelerikDropDownList> | ||
|
||
<TelerikComboBox Data="@ListItems" | ||
@bind-Value="@SelectedValue" | ||
TextField="@nameof(ListItem.Text)" | ||
ValueField="@nameof(ListItem.Id)" | ||
ScrollMode="@DropDownScrollMode.Virtual" | ||
ItemHeight="30" | ||
PageSize="12" | ||
Filterable="true" | ||
FilterOperator="@StringFilterOperator.Contains" | ||
Width="160px"> | ||
<ComboBoxSettings> | ||
<ComboBoxPopupSettings Class="no-wrap" Height="200px" /> | ||
</ComboBoxSettings> | ||
</TelerikComboBox> | ||
|
||
<style> | ||
.no-wrap { | ||
white-space: nowrap; | ||
} | ||
</style> | ||
|
||
@code { | ||
private List<ListItem> ListItems { get; set; } = new(); | ||
|
||
private int SelectedValue { get; set; } = 3; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
ListItems = new List<ListItem>(); | ||
|
||
for (int i = 1; i <= 64; i++) | ||
{ | ||
ListItems.Add(new ListItem() | ||
{ | ||
Id = i, | ||
Text = $"{i} Item with a lot of text that may wrap {i}" | ||
}); | ||
} | ||
|
||
base.OnInitialized(); | ||
} | ||
|
||
public class ListItem | ||
{ | ||
public int Id { get; set; } | ||
public string Text { get; set; } = string.Empty; | ||
} | ||
} | ||
```` | ||
|
||
## See Also | ||
|
||
* [AutoComplete Popup Setttings](slug:autocomplete-overview#popup-settings) | ||
* [ComboBox Popup Setttings](slug:components/combobox/overview#popup-settings) | ||
* [DropDownList Popup Setttings](slug:components/dropdownlist/overview#popup-settings) | ||
* [DropDownList Popup Setttings](slug:multiselect-overview#popup-settings) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should not be an ordered list, since they are two separate scenarios. I recommend going with simple bullets instead (unordered list).