Skip to content

Commit

Permalink
Fluent: increase send box text size to prevent unwanted zoom on mobile (
Browse files Browse the repository at this point in the history
#5192)

* Fluent: increase focused send box text size to prevent unwanted zoom on mobile

* Self review

* Changelog
  • Loading branch information
OEvgeny authored May 28, 2024
1 parent 6eb0f92 commit 058cccb
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
- Improved performance for `BasicTranscript`, in PR [5183](https://github.com/microsoft/BotFramework-WebChat/pull/5183), by [@OEvgeny](https://github.com/OEvgeny)
- Fixed potential memory usage issues caused by `useActivitiesWithRenderer`, in PR [5183](https://github.com/microsoft/BotFramework-WebChat/pull/5183), by [@OEvgeny](https://github.com/OEvgeny)
- Improved performance for `useMemoized`, in PR [5190](https://github.com/microsoft/BotFramework-WebChat/pull/5190), by [@OEvgeny](https://github.com/OEvgeny)
- Fixed send box zoomed in when clicked on mobile Safari, in PR [5192](https://github.com/microsoft/BotFramework-WebChat/pull/5192), by [@OEvgeny](https://github.com/OEvgeny)

### Changed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions __tests__/html/fluentTheme/simple.coarsePointer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script>
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
<script crossorigin="anonymous" src="/__dist__/botframework-webchat-fluent-theme.production.min.js"></script>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel">
run(async function () {
const {
React,
ReactDOM: { render },
WebChat: { FluentThemeProvider, ReactWebChat }
} = window; // Imports in UMD fashion.

// GIVEN: On mobile device
await host.sendDevToolsCommand('Emulation.setTouchEmulationEnabled', {
enabled: true,
configuration: 'mobile'
});

const directLine = testHelpers.createDirectLineWithTranscript(
testHelpers.transcriptNavigation.generateTranscript()
);
const store = testHelpers.createStore();

const App = () => <ReactWebChat directLine={directLine} store={store} />;

render(
<FluentThemeProvider>
<App />
</FluentThemeProvider>,
document.getElementById('webchat')
);

await pageConditions.uiConnected();

document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).focus();

// WHEN: Typing text on mobile
await host.sendKeys('A quick brown fox jumped over the lazy dog.');

// THEN: Increases font-size to prevent zoom-in action
await host.snapshot();

// WHEN: Removing focus from the text box
document.querySelector(`[data-testid="${WebChat.testIds.sendBoxTextBox}"]`).blur();

// THEN: Decreases font-size back
await host.snapshot();
});
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions __tests__/html/fluentTheme/simple.coarsePointer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */

describe('Fluent theme applied', () => {
test('should handle coarse pointer', () => runHTML('fluentTheme/simple.coarsePointer'));
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
outline: none;
padding: 4px 4px 0;
resize: none;

/* Prevent zoom on focus on iOS */
@media only screen and (hover: none) and (pointer: coarse) {
&:focus-within {
font-size: 16px;
}
}
}

:global(.webchat-fluent) .sendbox__sendbox-controls {
Expand Down

0 comments on commit 058cccb

Please sign in to comment.