Skip to content

Commit ac804b0

Browse files
mkapalMartin Kapal
andauthored
feat(intellij): autofocus first empty text field in re/move dialog (#2131)
Co-authored-by: Martin Kapal <[email protected]>
1 parent 5b1a05b commit ac804b0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

apps/intellij/src/main/kotlin/dev/nx/console/generate/NxReMoveProjectDialog.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.intellij.openapi.ui.ValidationInfo
1212
import com.intellij.ui.TextFieldWithAutoCompletion
1313
import com.intellij.ui.components.JBTextField
1414
import com.intellij.ui.dsl.builder.*
15+
import com.intellij.util.applyIf
1516
import dev.nx.console.models.NxGeneratorContext
1617
import dev.nx.console.models.WorkspaceLayout
1718
import java.awt.event.ActionEvent
@@ -84,6 +85,11 @@ class NxReMoveProjectDialog(
8485
)
8586
.comment(getShortcutHint())
8687
.align(AlignX.FILL)
88+
.applyIf(
89+
reMoveGeneratorContext?.project.isNullOrEmpty()
90+
) {
91+
focused()
92+
}
8793

8894
addDocumentListener(
8995
object : BulkAwareDocumentListener.Simple {
@@ -115,7 +121,13 @@ class NxReMoveProjectDialog(
115121
updateDestinationDirHint(model.project)
116122

117123
destinationField =
118-
textField().bindText(model::directory).align(AlignX.FILL).component
124+
textField()
125+
.bindText(model::directory)
126+
.align(AlignX.FILL)
127+
.applyIf(!reMoveGeneratorContext?.project.isNullOrEmpty()) {
128+
focused()
129+
}
130+
.component
119131
}
120132
.visible(mode == "move")
121133
.layout(RowLayout.PARENT_GRID)

0 commit comments

Comments
 (0)