Skip to content

Commit 65ea764

Browse files
authored
fix: add autofocus to auth fields (#6483)
1 parent 4b2fddd commit 65ea764

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

src/core/components/auth/api-key-auth.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default class ApiKeyAuth extends React.Component {
7070
<label>Value:</label>
7171
{
7272
value ? <code> ****** </code>
73-
: <Col><Input type="text" onChange={ this.onChange }/></Col>
73+
: <Col><Input type="text" onChange={ this.onChange } autoFocus/></Col>
7474
}
7575
</Row>
7676
{

src/core/components/auth/basic-auth.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default class BasicAuth extends React.Component {
6666
<label>Username:</label>
6767
{
6868
username ? <code> { username } </code>
69-
: <Col><Input type="text" required="required" name="username" onChange={ this.onChange }/></Col>
69+
: <Col><Input type="text" required="required" name="username" onChange={ this.onChange } autoFocus/></Col>
7070
}
7171
</Row>
7272
<Row>

src/core/components/auth/oauth2.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default class Oauth2 extends React.Component {
148148
{
149149
isAuthorized ? <code> { this.state.username } </code>
150150
: <Col tablet={10} desktop={10}>
151-
<input id="oauth_username" type="text" data-name="username" onChange={ this.onInputChange }/>
151+
<input id="oauth_username" type="text" data-name="username" onChange={ this.onInputChange } autoFocus/>
152152
</Col>
153153
}
154154
</Row>

test/e2e-cypress/tests/features/oauth2-flows/application.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ describe("OAuth2 Application flow", function() {
77
}).as("tokenRequest")
88
})
99

10+
// https://github.com/swagger-api/swagger-ui/issues/6395
11+
it("should have first authorization input autofocused", () => {
12+
cy
13+
.visit("/?url=http://localhost:3231/swagger.yaml")
14+
.get(".btn.authorize")
15+
.click()
16+
17+
cy.focused()
18+
.should("have.id", "oauth_username")
19+
})
20+
1021
it("should make an application flow Authorization header request", () => {
1122
cy
1223
.visit("/?url=http://localhost:3231/swagger.yaml")
@@ -52,4 +63,4 @@ describe("OAuth2 Application flow", function() {
5263
.get(".live-responses-table .response-col_status")
5364
.contains("200")
5465
})
55-
})
66+
})

0 commit comments

Comments
 (0)