Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase the width of the chat area on mobile devices #8374

Open
5 tasks done
yusuke-ten opened this issue Sep 13, 2024 · 1 comment · May be fixed by #8375
Open
5 tasks done

Increase the width of the chat area on mobile devices #8374

yusuke-ten opened this issue Sep 13, 2024 · 1 comment · May be fixed by #8375
Labels
💪 enhancement New feature or request

Comments

@yusuke-ten
Copy link
Contributor

Self Checks

  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

  • In the case of mobile, when the icon and message are side by side, the display area becomes narrow.
  • When opening the chat on mobile Safari, it can scroll horizontally.

2. Additional context or comments

No response

3. Can you help us with this feature?

  • I am interested in contributing to this feature.
Copy link

dosubot bot commented Sep 13, 2024

To increase the width of the chat area on mobile devices and prevent horizontal scrolling in mobile Safari, you can modify the CSS classes used in the Chat component. Specifically, ensure that the chat container and its inner elements have a width that adapts to the viewport width.

Here's how you can adjust the relevant parts of the Chat component:

  1. Ensure the chat container and its inner elements have a width of 100% to adapt to the viewport width.
  2. Add CSS rules to handle the mobile-specific styles.

Modify the Chat component as follows:

const Chat: FC<ChatProps> = ({
  // ... other props
}) => {
  // ... other hooks and state

  return (
    <ChatContextProvider
      // ... other props
    >
      <div className='relative h-full'>
        <div
          ref={chatContainerRef}
          className={classNames('relative h-full overflow-y-auto overflow-x-hidden w-full', chatContainerClassName)}
        >
          {chatNode}
          <div
            ref={chatContainerInnerRef}
            className={classNames('w-full', !noSpacing && 'px-8', chatContainerInnerClassName)}
          >
            {
              chatList.map((item, index) => {
                if (item.isAnswer) {
                  const isLast = item.id === chatList[chatList.length - 1]?.id
                  return (
                    <Answer
                      appData={appData}
                      key={item.id}
                      item={item}
                      question={chatList[index - 1]?.content}
                      index={index}
                      config={config}
                      answerIcon={answerIcon}
                      responding={isLast && isResponding}
                      allToolIcons={allToolIcons}
                      showPromptLog={showPromptLog}
                      chatAnswerContainerInner={chatAnswerContainerInner}
                      hideProcessDetail={hideProcessDetail}
                    />
                  )
                }
                return (
                  <Question
                    key={item.id}
                    item={item}
                    questionIcon={questionIcon}
                    theme={themeBuilder?.theme}
                  />
                )
              })
            }
          </div>
        </div>
        <div
          className={`absolute bottom-0 w-full ${(hasTryToAsk || !noChatInput || !noStopResponding) && chatFooterClassName}`}
          ref={chatFooterRef}
          style={{
            background: 'linear-gradient(0deg, #F9FAFB 40%, rgba(255, 255, 255, 0.00) 100%)',
          }}
        >
          <div
            ref={chatFooterInnerRef}
            className={`w-full ${chatFooterInnerClassName}`}
          >
            {
              !noStopResponding && isResponding && (
                <div className='flex justify-center mb-2'>
                  <Button onClick={onStopResponding}>
                    <StopCircle className='mr-[5px] w-3.5 h-3.5 text-gray-500' />
                    <span className='text-xs text-gray-500 font-normal'>{t('appDebug.operation.stopResponding')}</span>
                  </Button>
                </div>
              )
            }
            {
              hasTryToAsk && (
                <TryToAsk
                  suggestedQuestions={suggestedQuestions}
                  onSend={onSend}
                />
              )
            }
            {
              !noChatInput && (
                <ChatInput
                  visionConfig={config?.file_upload?.image}
                  speechToTextConfig={config?.speech_to_text}
                  onSend={onSend}
                  theme={themeBuilder?.theme}
                  noSpacing={noSpacing}
                />
              )
            }
          </div>
        </div>
        {showPromptLogModal && !hideLogModal && (
          <PromptLogModal
            width={width}
            currentLogItem={currentLogItem}
            onCancel={() => {
              setCurrentLogItem()
              setShowPromptLogModal(false)
            }}
          />
        )}
        {showAgentLogModal && !hideLogModal && (
          <AgentLogModal
            width={width}
            currentLogItem={currentLogItem}
            onCancel={() => {
              setCurrentLogItem()
              setShowAgentLogModal(false)
            }}
          />
        )}
      </div>
    </ChatContextProvider>
  )
}

In this modification, the w-full class is added to ensure the chat container and its inner elements take the full width of the viewport, preventing horizontal scrolling on mobile devices [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the 💪 enhancement New feature or request label Sep 13, 2024
@crazywoola crazywoola linked a pull request Sep 13, 2024 that will close this issue
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant