Skip to content

Commit

Permalink
feat: Add global initialFocus configuration (#7775)
Browse files Browse the repository at this point in the history
Co-authored-by: jcesarmobile <jcesarmobile@gmail.com>
  • Loading branch information
theproducer and jcesarmobile authored Dec 18, 2024
1 parent 9fe2256 commit 61d0165
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ private void deserializeConfig(@Nullable Context context) {
loggingEnabled = isDebug;
}

initialFocus = JSONUtils.getBoolean(configJSON, "android.initialFocus", initialFocus);
initialFocus = JSONUtils.getBoolean(
configJSON,
"android.initialFocus",
JSONUtils.getBoolean(configJSON, "initialFocus", initialFocus)
);

// Plugins
pluginsConfiguration = deserializePluginsConfig(JSONUtils.getObject(configJSON, "plugins"));
Expand Down
12 changes: 12 additions & 0 deletions cli/src/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ export interface CapacitorConfig {
*/
zoomEnabled?: boolean;

/**
* Whether to give the webview initial focus.
*
* @since 7.0.0
* @default true
*/
initialFocus?: boolean;

android?: {
/**
* Specify a custom path to the native Android project.
Expand Down Expand Up @@ -191,6 +199,8 @@ export interface CapacitorConfig {
/**
* Whether to give the webview initial focus.
*
* Overrides global `initialFocus` option.
*
* @since 3.5.1
* @default true
*/
Expand Down Expand Up @@ -453,6 +463,8 @@ export interface CapacitorConfig {
/**
* Whether to give the webview initial focus.
*
* Overrides global `initialFocus` option.
*
* @since 7.0.0
* @default true
*/
Expand Down
2 changes: 1 addition & 1 deletion ios/Capacitor/Capacitor/CAPInstanceDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ internal extension InstanceDescriptor {
isWebDebuggable = true
#endif
}
if let initialFocus = config[keyPath: "ios.initialFocus"] as? Bool {
if let initialFocus = (config[keyPath: "ios.initialFocus"] as? Bool) ?? (config[keyPath: "initialFocus"] as? Bool) {
hasInitialFocus = initialFocus
}
}
Expand Down

0 comments on commit 61d0165

Please sign in to comment.