mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
[Glitch] Hide empty state of topic suggestions dropdown in Collection editor
Port bafc552a72 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Fragment, useCallback, useMemo, useState } from 'react';
|
import { Fragment, useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
@@ -10,7 +10,6 @@ import { languages } from '@/flavours/glitch/initial_state';
|
|||||||
import {
|
import {
|
||||||
hasSpecialCharacters,
|
hasSpecialCharacters,
|
||||||
inputToHashtag,
|
inputToHashtag,
|
||||||
trimHashFromStart,
|
|
||||||
} from '@/flavours/glitch/utils/hashtags';
|
} from '@/flavours/glitch/utils/hashtags';
|
||||||
import type {
|
import type {
|
||||||
ApiCreateCollectionPayload,
|
ApiCreateCollectionPayload,
|
||||||
@@ -297,14 +296,7 @@ export const CollectionDetails: React.FC = () => {
|
|||||||
const TopicField: React.FC = () => {
|
const TopicField: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const { id, topic } = useAppSelector((state) => state.collections.editor);
|
const { topic } = useAppSelector((state) => state.collections.editor);
|
||||||
|
|
||||||
const collection = useAppSelector((state) =>
|
|
||||||
id ? state.collections.collections[id] : undefined,
|
|
||||||
);
|
|
||||||
const [isInitialValue, setIsInitialValue] = useState(
|
|
||||||
() => trimHashFromStart(topic) === (collection?.tag?.name ?? ''),
|
|
||||||
);
|
|
||||||
|
|
||||||
const { tags, isLoading, searchTags } = useSearchTags({
|
const { tags, isLoading, searchTags } = useSearchTags({
|
||||||
query: topic,
|
query: topic,
|
||||||
@@ -312,7 +304,6 @@ const TopicField: React.FC = () => {
|
|||||||
|
|
||||||
const handleTopicChange = useCallback(
|
const handleTopicChange = useCallback(
|
||||||
(event: React.ChangeEvent<HTMLInputElement>) => {
|
(event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setIsInitialValue(false);
|
|
||||||
dispatch(
|
dispatch(
|
||||||
updateCollectionEditorField({
|
updateCollectionEditorField({
|
||||||
field: 'topic',
|
field: 'topic',
|
||||||
@@ -379,7 +370,7 @@ const TopicField: React.FC = () => {
|
|||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
suppressMenu={isInitialValue}
|
suppressMenu={!tags.length}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user