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

Adding handler for pressing <enter> key to connect in Connection Dialog #18525

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ConnectionDialogContext } from "./../connectionDialogStateProvider";
import { ApiStatus } from "../../../../sharedInterfaces/webview";
import { locConstants } from "../../../common/locConstants";

export const ConnectButtonId = "connectButton";

export const ConnectButton = ({
style,
className,
Expand All @@ -24,6 +26,8 @@ export const ConnectButton = ({

return (
<Button
id={ConnectButtonId}
type="submit"
appearance="primary"
disabled={
connectionDialogContext.state.connectionStatus ===
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { TrustServerCertificateDialog } from "./components/trustServerCertificat
import { locConstants } from "../../common/locConstants";
import { themeType } from "../../common/utils";
import { AddFirewallRuleDialog } from "./components/addFirewallRule.component";
import { ConnectButtonId } from "./components/connectButton.component";

function renderContent(
connectionDialogContext: ConnectionDialogContextProps,
Expand Down Expand Up @@ -61,8 +62,13 @@ export const ConnectionInfoFormContainer = () => {
return saveIcon;
}

function handleSubmit(event: React.FormEvent) {
event.preventDefault();
document.getElementById(ConnectButtonId)?.click();
}

return (
<div className={formStyles.formRoot}>
<form onSubmit={handleSubmit} className={formStyles.formRoot}>
<ConnectionHeader />

<div className={formStyles.formDiv} style={{ overflow: "auto" }}>
Expand Down Expand Up @@ -177,6 +183,6 @@ export const ConnectionInfoFormContainer = () => {
</div>
{renderContent(context)}
</div>
</div>
</form>
);
};
Loading