diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index b7237711de..6fa4e6d78f 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -703,6 +703,7 @@ website = Website location = Location pronouns = Pronouns pronouns_custom = Custom +pronouns_unspecified = Unspecified update_theme = Change theme update_profile = Update profile update_language = Change language diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index 6843340fec..1b1cdb54d4 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -46,7 +46,7 @@ func Profile(ctx *context.Context) { ctx.Data["PageIsSettingsProfile"] = true ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice() ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx) - ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" + ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "" && ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" ctx.HTML(http.StatusOK, tplSettingsProfile) } @@ -57,7 +57,7 @@ func ProfilePost(ctx *context.Context) { ctx.Data["PageIsSettingsProfile"] = true ctx.Data["AllowedUserVisibilityModes"] = setting.Service.AllowedUserVisibilityModesSlice.ToVisibleTypeSlice() ctx.Data["DisableGravatar"] = setting.Config().Picture.DisableGravatar.Value(ctx) - ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" + ctx.Data["PronounsAreCustom"] = ctx.Doer.Pronouns != "" && ctx.Doer.Pronouns != "he/him" && ctx.Doer.Pronouns != "she/her" && ctx.Doer.Pronouns != "they/them" && ctx.Doer.Pronouns != "it/its" if ctx.HasError() { ctx.HTML(http.StatusOK, tplSettingsProfile) diff --git a/templates/user/settings/profile.tmpl b/templates/user/settings/profile.tmpl index 822651a9db..9d279f23a2 100644 --- a/templates/user/settings/profile.tmpl +++ b/templates/user/settings/profile.tmpl @@ -44,12 +44,15 @@ <div class="text"> {{if .PronounsAreCustom}} {{.locale.Tr "settings.pronouns_custom"}} + {{else if eq "" .SignedUser.Pronouns}} + {{.locale.Tr "settings.pronouns_unspecified"}} {{else}} {{.SignedUser.Pronouns}} {{end}} </div> {{svg "octicon-triangle-down" 14 "dropdown icon"}} <div class="menu"> + <div class="item{{if eq "" .SignedUser.Pronouns}} active selected{{end}}" data-value=""><i>{{.locale.Tr "settings.pronouns_unspecified"}}</i></div> <div class="item{{if eq "he/him" .SignedUser.Pronouns}} active selected{{end}}" data-value="he/him">he/him</div> <div class="item{{if eq "she/her" .SignedUser.Pronouns}} active selected{{end}}" data-value="she/her">she/her</div> <div class="item{{if eq "they/them" .SignedUser.Pronouns}} active selected{{end}}" data-value="they/them">they/them</div> @@ -57,7 +60,7 @@ {{if .PronounsAreCustom}} <div class="item active selected" data-value="{{.SignedUser.Pronouns}}">{{.locale.Tr "settings.pronouns_custom"}}</div> {{else}} - <div class="item" data-value="">{{.locale.Tr "settings.pronouns_custom"}}</div> + <div class="item" data-value="!">{{.locale.Tr "settings.pronouns_custom"}}</div> {{end}} </div> </div> diff --git a/web_src/js/features/user-settings.js b/web_src/js/features/user-settings.js index d2617dda6a..ec99f168fe 100644 --- a/web_src/js/features/user-settings.js +++ b/web_src/js/features/user-settings.js @@ -2,15 +2,21 @@ import {hideElem, showElem} from '../utils/dom.js'; function onPronounsDropdownUpdate() { const pronounsCustom = document.getElementById('pronouns-custom'); - const pronounsInput = document.querySelector('#pronouns-dropdown input'); + const pronounsDropdown = document.getElementById('pronouns-dropdown'); + const pronounsInput = pronounsDropdown.querySelector('input'); const isCustom = !( + pronounsInput.value === '' || pronounsInput.value === 'he/him' || pronounsInput.value === 'she/her' || pronounsInput.value === 'they/them' || pronounsInput.value === 'it/its' ); if (isCustom) { - pronounsCustom.value = pronounsInput.value; + if (pronounsInput.value === '!') { + pronounsCustom.value = ''; + } else { + pronounsCustom.value = pronounsInput.value; + } pronounsCustom.style.display = ''; } else { pronounsCustom.style.display = 'none';