Skip to content
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

Fix: Selects on docs shrinks to unusable sizes on mobile #18863

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 37 additions & 19 deletions modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -332,28 +332,46 @@
</abp-column>
</abp-row>
<abp-row class="gx-2">
@foreach (var parameter in Model.DocumentPreferences.Parameters)
{
<div class="col">
<div class="custom-input-group">
<span class="input-group-text" id="@("Section" + parameter.Name + "ComboboxAddonId")">@(parameter.DisplayName)</span>
<select class="doc-section-combobox form-select"
aria-describedby="@("Section" + parameter.Name + "ComboboxAddonId")"
id="@("Section" + parameter.Name + "ComboboxId")" data-key="@parameter.Name">
@foreach (var value in parameter.Values.OrderBy(p => p.Value))
{
@if (value.Key == (Model.UserPreferences.ContainsKey(parameter.Name) ? Model.UserPreferences[parameter.Name] : null))
{
<option value="@value.Key" selected="selected">@value.Value</option>
}
else
@{
const int maxCellCount = 3;
var count = Model.DocumentPreferences.Parameters.Count;
var rowCount = count / maxCellCount + (count % maxCellCount > 0 ? 1 : 0);
var cellSize = 12 / (count > maxCellCount ? maxCellCount : count);
var latestCellSize = 12 / count - (rowCount - 1) * maxCellCount;

string BuildParameterDivClass(int index)
{
var row = index / maxCellCount;
var isLastRow = row == rowCount - 1;
var currentCellSize = isLastRow ? latestCellSize : cellSize;
return $"col-12 col-lg-{currentCellSize} mb-lg-{(isLastRow ? "0" : "2")} {(index == count - 1 ? "" : "mb-2")}";
}

for (var i = 0; i < count; ++i)
{
var parameter = Model.DocumentPreferences.Parameters[i];

<div class="@BuildParameterDivClass(i)">
<div class="custom-input-group">
<span class="input-group-text" id="@("Section" + parameter.Name + "ComboboxAddonId")">@(parameter.DisplayName)</span>
<select class="doc-section-combobox form-select"
aria-describedby="@("Section" + parameter.Name + "ComboboxAddonId")"
id="@("Section" + parameter.Name + "ComboboxId")" data-key="@parameter.Name">
@foreach (var value in parameter.Values.OrderBy(p => p.Value))
{
<option value="@value.Key">@value.Value</option>
@if (value.Key == (Model.UserPreferences.ContainsKey(parameter.Name) ? Model.UserPreferences[parameter.Name] : null))
{
<option value="@value.Key" selected="selected">@value.Value</option>
}
else
{
<option value="@value.Key">@value.Value</option>
}
}
}
</select>
</select>
</div>
</div>
</div>
}
}
</abp-row>
</div>
Expand Down