title: How to keep only one edit form open at a time in a composable function
body: <p>I am showing a list of rows with one word in it, inside a LazyColumn. On clicking the row, an edit form opens. The data is coming from a room database.</p>
  <p>Since the row is on a separate composable function, I can open many different edit forms together (one in each row). But I want to show only one edit form in the whole list at a time. If I click one row to open an edit form, the rest of the open forms on the other rows should be closed. How can I do that?</p>
  <p>Here is the code:</p>
  <pre><code>    val words: List&lt;Word&gt; by wordViewModel.allWords.observeAsState(listOf())
  
      var newWord by remember { mutableStateOf(&quot;&quot;) }
      val context = LocalContext.current
      val keyboardController = LocalSoftwareKeyboardController.current
  
          LazyColumn(
              modifier = Modifier
                  .weight(1f)
                  .padding(vertical = 16.dp),
              verticalArrangement = Arrangement.spacedBy(4.dp)
          ) {
              items(words) { word -&gt;
                  WordItemLayout(
                      word = word,
                      onSaveUpdatedWord = { onUpdateWord(it) },
                      onTrashClicked = { onDeleteWord(it) }
                  )
              }
          }
  </code></pre>
  <pre><code>@Composable
  fun WordItemLayout(word: Word, onSaveUpdatedWord: (Word) -&gt; Unit, onTrashClicked: (Word) -&gt; Unit) {
      var showEditForm by remember { mutableStateOf(false) }
      var editedWord by remember { mutableStateOf(word.word) }
      val context = LocalContext.current
  
      Column {
          Row(
              modifier = Modifier
                  .fillMaxWidth()
                  .background(MaterialTheme.colors.primaryVariant)
                  .padding(vertical = 12.dp, horizontal = 24.dp)
                  .clickable {
                      showEditForm = !showEditForm
                      editedWord = word.word
                  },
              verticalAlignment = Alignment.CenterVertically,
          ) {
              Image(painter = painterResource(R.drawable.ic_star), contentDescription = null)
              Text(
                  text = word.word,
                  color = Color.White,
                  fontSize = 20.sp,
                  modifier = Modifier
                      .padding(start = 16.dp)
                      .weight(1f)
              )
              // Delete Button
              IconButton(
                  onClick = {
                      showEditForm = false
                      onTrashClicked(word)
                      Toast.makeText(context, &quot;Word deleted&quot;, Toast.LENGTH_SHORT).show()
                  },
                  modifier = Modifier.size(12.dp)
              ) {
                  Icon(
                      imageVector = Icons.Filled.Delete,
                      contentDescription = &quot;Delete Word&quot;,
                      tint = Color.White
                  )
              }
          }
  
          // word edit form
          if (showEditForm) {
              Row(
                  modifier = Modifier.fillMaxWidth(),
                  verticalAlignment = Alignment.Bottom
              ) {
                  TextField(
                      value = editedWord,
                      onValueChange = { editedWord = it },
                      modifier = Modifier.weight(1f),
                      colors = TextFieldDefaults.textFieldColors(backgroundColor = Color.White) // TextField Background Color
                  )
                  // Update Button
                  Button(
                      onClick = {
                          val updatedWord: Word = word
  
                          if (updatedWord.word != editedWord.trim()) {
                              updatedWord.word = editedWord.trim()
                              onSaveUpdatedWord(updatedWord)
                              Toast.makeText(context, &quot;Word updated&quot;, Toast.LENGTH_SHORT).show()
                          }
  
                          showEditForm = false
                      },
                      modifier = Modifier.padding(start = 8.dp)
                  ) {
                      Icon(imageVector = Icons.Filled.Done, contentDescription = &quot;Update Word&quot;)
                  }
              }
          }
      }
  }
  </code></pre>
  <p>Thanks for your help!</p>