2
0

Fix hashtags not being picked up when full-width hash sign is used (#36103)

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Eugen Rochko
2025-10-27 18:18:01 +01:00
committed by GitHub
parent 402686c76c
commit 76053fb4a9
7 changed files with 27 additions and 10 deletions

View File

@@ -622,6 +622,7 @@ export function fetchComposeSuggestions(token) {
fetchComposeSuggestionsEmojis(dispatch, getState, token);
break;
case '#':
case '':
fetchComposeSuggestionsTags(dispatch, getState, token);
break;
default:
@@ -663,11 +664,11 @@ export function selectComposeSuggestion(position, token, suggestion, path) {
dispatch(useEmoji(suggestion));
} else if (suggestion.type === 'hashtag') {
completion = `#${suggestion.name}`;
startPosition = position - 1;
completion = suggestion.name.slice(token.length - 1);
startPosition = position + token.length;
} else if (suggestion.type === 'account') {
completion = getState().getIn(['accounts', suggestion.id, 'acct']);
startPosition = position;
completion = `@${getState().getIn(['accounts', suggestion.id, 'acct'])}`;
startPosition = position - 1;
}
// We don't want to replace hashtags that vary only in case due to accessibility, but we need to fire off an event so that
@@ -727,7 +728,7 @@ function insertIntoTagHistory(recognizedTags, text) {
// complicated because of new normalization rules, it's no longer just
// a case sensitivity issue
const names = recognizedTags.map(tag => {
const matches = text.match(new RegExp(`#${tag.name}`, 'i'));
const matches = text.match(new RegExp(`[#]${tag.name}`, 'i'));
if (matches && matches.length > 0) {
return matches[0].slice(1);

View File

@@ -61,7 +61,7 @@ export default class AutosuggestInput extends ImmutablePureComponent {
static defaultProps = {
autoFocus: true,
searchTokens: ['@', ':', '#'],
searchTokens: ['@', '', ':', '#', ''],
};
state = {

View File

@@ -25,7 +25,7 @@ const textAtCursorMatchesToken = (str, caretPosition) => {
word = str.slice(left, right + caretPosition);
}
if (!word || word.trim().length < 3 || ['@', ':', '#'].indexOf(word[0]) === -1) {
if (!word || word.trim().length < 3 || ['@', '', ':', '#', ''].indexOf(word[0]) === -1) {
return [null, null];
}