Commit 6cd813cc authored by Marek Veselý's avatar Marek Veselý
Browse files

Merge branch 'fix-scroll-after-submit' into 'main'

Fix scroll after submit

Closes #873

See merge request inject/frontend!759
parents 222e11a1 677d9a71
Loading
Loading
Loading
Loading
Compare e42c8422 to 02206a45
Original line number Diff line number Diff line
Subproject commit e42c8422f8db4a3371bda22aad3e7f1ed7e62640
Subproject commit 02206a454c51c8988e2cb1fb53b6c8e746ae693c
+3 −5
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ const scrollable = css`
  margin-bottom: 4rem;
`

const ListRenderer: FC<{
export const ListRenderer: FC<{
  actionLogs: ActionLog[]
  exerciseId: string
  teamId: string
@@ -113,7 +113,7 @@ const ListRenderer: FC<{
        ref.scrollTo({ top: ref.scrollHeight, behavior: 'instant' })
      }
    }
  }, [actionLogs])
  }, [actionLogs.length])

  /*
   * Logs with timestampRead === undefined should be rendered as unread
@@ -142,7 +142,7 @@ const ListRenderer: FC<{
      }
    }
    actionLogsLengthPrev.current = actionLogs.length
  }, [actionLogs, firstUnreadId, getFirstUnreadId, scrollToLast])
  }, [actionLogs.length, firstUnreadId, getFirstUnreadId, scrollToLast])

  return (
    <div className={cx(view, { [instructorView]: inInstructor })} id='channel'>
@@ -214,5 +214,3 @@ const ListRenderer: FC<{
    </div>
  )
}

export default ListRenderer
+9 −8
Original line number Diff line number Diff line
import { NonIdealState, type NonIdealStateProps } from '@blueprintjs/core'
import { css } from '@emotion/css'
import { ChannelActionLogsQuery, useTypedQuery } from '@inject/graphql'
import { CenteredSpinner } from '@inject/shared'
import type { NavigateOptions } from '@tanstack/react-router'
import { type FC, useMemo } from 'react'
import ListRenderer from './ListRenderer'
import { ListRenderer } from './ListRenderer'

interface ActionLogProps {
  teamId: string
@@ -29,7 +29,7 @@ export const ActionLog: FC<ActionLogProps> = ({
  scrollToLast,
  getFileLink,
}) => {
  const [{ data }] = useTypedQuery({
  const [{ data, fetching }] = useTypedQuery({
    query: ChannelActionLogsQuery,
    variables: {
      teamIds: [teamId],
@@ -43,19 +43,20 @@ export const ActionLog: FC<ActionLogProps> = ({
    ),
  })

  if (fetching) {
    return <CenteredSpinner />
  }

  if (!data) {
    return (
      <NonIdealState
        icon='low-voltage-pole'
        title='Channel not found'
        className={css`
          height: 80vh;
          width: 100%;
        `}
        {...noDataProps}
        description='Channel data could not be loaded.'
      />
    )
  }

  return (
    <ListRenderer
      getFileLink={getFileLink}
+0 −1
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import { commitActionLogsToCache } from './cacheFunctions/commitActionLogsToCach
import { commitInstructorCommentToCache } from './cacheFunctions/commitInstructorCommentToCache'
import invalidateUserList from './cacheFunctions/invalidateUserList'

// TODO: 3.34.0 follow-up (fix rerender after submitting questionnaire and confirmation button)
// TODO: 3.34.0 follow-up (fix rerender after changing milestones in instructor)
// TODO: 3.34.0 follow-up (make sure questionnaire and confirmation is updated when submitted in another tab (subscription))