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

Provide an API for clearing input #245

Open
wwwillchen opened this issue May 13, 2024 · 1 comment
Open

Provide an API for clearing input #245

wwwillchen opened this issue May 13, 2024 · 1 comment

Comments

@wwwillchen
Copy link
Collaborator

wwwillchen commented May 13, 2024

Context: https://github.com/google/mesop/pull/242/files#r1597977597

@richard-to
Copy link
Collaborator

For the markdown editor, I was able to clear the input using two yields, which avoids needing to keep updating the key name. So still pretty hacky implementation wise, so I definitely think this would be a nice API to have.

def on_click_new(e: me.ClickEvent):
  state = me.state(State)
  # Need to update the initial value of the editor text area so we can
  # trigger a diff to reset the editor to empty. Need to yield this change.
  # for this to work.
  state.selected_note_content = state.notes[state.selected_note_index].content
  yield
  # Reset the initial value of the editor text area to empty since the new note
  # has no content.
  state.selected_note_content = ""
  state.notes.append(Note())
  state.selected_note_index = len(state.notes) - 1
  yield

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants