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

fix: added missing prevent ios mobile zoom trick #361

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/components/chat/ui/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@linaria/core';
import { css, cx } from '@linaria/core';
import { useRef, useState } from 'react';

import useSendbirdStateContext from '@uikit/hooks/useSendbirdStateContext';
Expand All @@ -24,7 +24,7 @@ export const ChatInput = () => {
});

return (
<div className={container}>
<div className={cx(container, isIOSMobile && iosMobileContainer)}>
<MessageInputWrapperView
loading={false}
disabled={config.isOnline ? isMessageInputDisabled : true}
Expand Down Expand Up @@ -52,6 +52,25 @@ export const ChatInput = () => {
);
};

// Not to zoom in on mobile set font-size to 16px which blocks the zooming on iOS
// @link: https://weblog.west-wind.com/posts/2023/Apr/17/Preventing-iOS-Safari-Textbox-Zooming
const iosMobileContainer = css`
&&&& {
.sendbird-message-input-text-field {
min-height: 40px;
height: 40px;
font-size: 16px;
line-height: 24px;
}
.sendbird-message-input--placeholder {
font-size: 16px;
}
.sendbird-message-input--attach {
inset-block-end: 4px;
}
}
`;

const container = css`
z-index: 0;
border: none;
Expand Down Expand Up @@ -82,9 +101,6 @@ const container = css`
padding-bottom: 8px;
padding-inline-start: 16px;
border-radius: 20px;
// Not to zoom in on mobile set font-size to 16px which blocks the zooming on iOS
// @link: https://weblog.west-wind.com/posts/2023/Apr/17/Preventing-iOS-Safari-Textbox-Zooming
font-size: ${isIOSMobile ? 16 : 14}px;
Copy link
Contributor Author

@bang9 bang9 Sep 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have experimentally applied a tool called Linaria.
Linaria converts style code written in JS into CSS at compile time.

So we cannot use dynamic variables at compile time, so I've moved them to separate styles and using them at runtime.

resize: none;
border: none;
outline: none;
Expand Down