Profile editing: Fix regression with adding tags (#38580)

This commit is contained in:
Echo 2026-04-07 14:05:06 +02:00 committed by GitHub
parent ed6ceda71d
commit 85fb9218a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 7 deletions

View File

@ -65,7 +65,7 @@ export const AccountEditTagSearch: FC = () => {
value={query}
onChange={handleSearchChange}
placeholder={inputLabel}
items={suggestedTags as TagSearchResult[]}
items={suggestedTags}
isLoading={isLoading}
renderItem={renderItem}
onSelectItem={handleSelect}

View File

@ -14,20 +14,27 @@ import {
fetchSuggestedTags,
addFeaturedTags,
} from '@/mastodon/reducers/slices/profile_edit';
import { useAppSelector, useAppDispatch } from '@/mastodon/store';
import {
useAppSelector,
useAppDispatch,
createAppSelector,
} from '@/mastodon/store';
import classes from './styles.module.scss';
const MAX_SUGGESTED_TAGS = 3;
const selectSuggestedTags = createAppSelector(
[(state) => state.profileEdit.tagSuggestions],
(tagSuggestions) => tagSuggestions?.slice(0, MAX_SUGGESTED_TAGS),
);
export const TagSuggestions: FC = () => {
const { dismiss, wasDismissed } = useDismissible(
'profile/featured_tag_suggestions',
);
const suggestedTags = useAppSelector((state) =>
state.profileEdit.tagSuggestions?.slice(0, MAX_SUGGESTED_TAGS),
);
const suggestedTags = useAppSelector(selectSuggestedTags);
const existingTagCount = useAppSelector(
(state) => state.profileEdit.profile?.featuredTags.length,
);

View File

@ -91,8 +91,8 @@ export function useSearchTags({
// Add dedicated item for adding the current query
const tags = useMemo(() => {
const trimmedQuery = query ? trimHashFromStart(query.trim()) : '';
if (!trimmedQuery || !fetchedTags.length) {
return fetchedTags;
if (!trimmedQuery) {
return fetchedTags as TagSearchResult[];
}
const results: TagSearchResult[] = [...fetchedTags]; // Make array mutable