diff --git a/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx index 1856b7109e..b7225fc92e 100644 --- a/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx +++ b/app/javascript/flavours/glitch/components/__tests__/hashtag_bar.tsx @@ -45,6 +45,21 @@ describe('computeHashtagBarForStatus', () => { ); }); + it('does not truncate the contents when the last child is a text node', () => { + const status = createStatus( + 'this is a #test. Some more text', + ['test'], + ); + + const { hashtagsInBar, statusContentProps } = + computeHashtagBarForStatus(status); + + expect(hashtagsInBar).toEqual([]); + expect(statusContentProps.statusContent).toMatchInlineSnapshot( + `"this is a #test. Some more text"`, + ); + }); + it('extract tags from the last line', () => { const status = createStatus( '

Simple text

#hashtag

', diff --git a/app/javascript/flavours/glitch/components/hashtag_bar.tsx b/app/javascript/flavours/glitch/components/hashtag_bar.tsx index d45a6e20eb..91fa922198 100644 --- a/app/javascript/flavours/glitch/components/hashtag_bar.tsx +++ b/app/javascript/flavours/glitch/components/hashtag_bar.tsx @@ -109,7 +109,7 @@ export function computeHashtagBarForStatus(status: StatusLike): { const lastChild = template.content.lastChild; - if (!lastChild) return defaultResult; + if (!lastChild || lastChild.nodeType === Node.TEXT_NODE) return defaultResult; template.content.removeChild(lastChild); const contentWithoutLastLine = template;