Skip to content

Commit

Permalink
WEB-1950 new message FOCUS_NAVBAR (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
atabel authored Jul 19, 2024
1 parent e4d83bc commit 5331ddb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,24 @@ triggerPinOrBiometricAuthentication: ({
is less than the number of seconds specified here authentication will
succeed without requesting it again.
### focusNavbar
<kbd>App version >= 24.9</kbd>
Sets the screen reader focus on the native navigation bar. If the webview
doesn't have a native navbar, the native app will respond with
`{focused: false}`.
This is useful for accessibility purposes. We need the focus to be set in the
navbar when we navigate to a new screen using client side navigation (React
Router).
```ts
focusNavbar: () => Promise<{
focused: boolean,
}>;
```
## Error handling
If an uncontrolled error occurs, promise will be rejected with an error object:
Expand Down
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export {
getPincodeInfo,
onNavigationBarIconClicked,
triggerPinOrBiometricAuthentication,
focusNavbar,
} from './src/utils';
export type {ShareOptions, NavigationBarIcon} from './src/utils';

Expand Down
7 changes: 7 additions & 0 deletions src/post-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ export type ResponsesFromNativeApp = {
| 'LAST_AUTHENTICATION_STILL_VALID';
};
};
FOCUS_NAVBAR: {
type: 'FOCUS_NAVBAR';
id: string;
payload: {
focused: boolean;
};
};
SHARE_BASE64: {
type: 'SHARE_BASE64';
id: string;
Expand Down
3 changes: 3 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,6 @@ export const triggerPinOrBiometricAuthentication = (
type: 'TRIGGER_PIN_OR_BIOMETRIC_AUTHENTICATION',
payload: {maxSecondsSinceLastValidation},
});

export const focusNavbar = (): Promise<{focused: boolean}> =>
postMessageToNativeApp({type: 'FOCUS_NAVBAR'});

0 comments on commit 5331ddb

Please sign in to comment.