{{if .CustomFieldDefs}}
<div class="divider"></div>
<div class="tw-flex tw-flex-col tw-gap-2">
	{{$issueID := .Issue.ID}}
	{{$repoLink := .RepoLink}}
	{{$canModify := .HasIssuesOrPullsWritePermission}}
	{{$values := .CustomFieldValues}}
	{{$fieldOptions := .CustomFieldOptions}}
	{{range .CustomFieldDefs}}
		{{$currentVal := index $values .ID}}
		<div class="tw-flex tw-items-center tw-justify-between tw-gap-2">
			<span class="text grey tw-text-sm" {{if .Description}}title="{{.Description}}"{{end}}>{{.Name}}</span>
			{{if and $canModify (eq .Options "")}}
				{{/* Non-dropdown: just display the value */}}
				<span class="tw-text-sm">{{if $currentVal}}{{$currentVal}}{{else}}<span class="text grey">—</span>{{end}}</span>
			{{else if $canModify}}
				<form method="post" action="{{$repoLink}}/issues/{{$issueID}}/custom-fields/{{.ID}}" class="tw-inline">
					{{$.CsrfTokenHtml}}
					<select name="value" class="ui compact mini dropdown tw-max-w-48" onchange="this.form.submit()">
						<option value="">—</option>
						{{$opts := index $fieldOptions .ID}}
						{{range $opts}}
							<option value="{{.}}" {{if eq . $currentVal}}selected{{end}}>{{.}}</option>
						{{end}}
					</select>
				</form>
			{{else}}
				<span class="tw-text-sm">{{if $currentVal}}{{$currentVal}}{{else}}<span class="text grey">—</span>{{end}}</span>
			{{end}}
		</div>
	{{end}}
</div>
{{end}}
