diff --git a/src/views/pending-post/pending-post.tsx b/src/views/pending-post/pending-post.tsx index 0aa2be50..7c285b98 100644 --- a/src/views/pending-post/pending-post.tsx +++ b/src/views/pending-post/pending-post.tsx @@ -14,10 +14,13 @@ const PendingPost = () => { const isValidAccountCommentIndex = !accountCommentIndex || + // Check if it's a valid positive integer (!isNaN(parseInt(accountCommentIndex)) && parseInt(accountCommentIndex) >= 0 && - accountComments?.length > 0 && - parseInt(accountCommentIndex) < accountComments.length); + Number.isInteger(parseFloat(accountCommentIndex)) && + // Allow index to be at most 1 position beyond the current length + // This handles the case where a new post is being created + (accountComments?.length === 0 || parseInt(accountCommentIndex) <= accountComments.length)); useEffect(() => { if (!isValidAccountCommentIndex) {