8000 Add enter_pressed option to TextInput by hoxbro · Pull Request #6593 · holoviz/panel · GitHub
[go: up one dir, main page]

Skip to content
8000

Conversation

@hoxbro
Copy link
Member
@hoxbro hoxbro commented Mar 27, 2024

This adds a counter to the number of times the enter key has been pressed. You can then watch this parameter, and you can make TextInput behave like a search bar.

TODO:

  • Suggestion for a better name
  • Add UI test
  • Add documentation
  • Maybe add it to _busy__ignore, not needed because we use it as an event.

@codecov
Copy link
codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 82.60870% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 82.95%. Comparing base (b3fcdad) to head (acbbeab).
Report is 6 commits behind head on main.

❗ Current head acbbeab differs from pull request most recent head 3058bfe. Consider uploading reports for the commit 3058bfe to get more accurate results

Files Patch % Lines
panel/widgets/input.py 75.00% 4 Missing ⚠️
panel/models/widgets.py 70.00% 3 Missing ⚠️
panel/tests/ui/widgets/test_input.py 94.11% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6593      +/-   ##
==========================================
+ Coverage   81.54%   82.95%   +1.41%     
==========================================
  Files         314      313       -1     
  Lines       46453    46127     -326     
==========================================
+ Hits        37879    38265     +386     
+ Misses       8574     7862     -712     
Flag Coverage Δ
ui-tests 40.05% <73.91%> (+2.58%) ⬆️
unitexamples-tests 71.22% <45.65%> (+0.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hoxbro hoxbro marked this pull request as draft March 28, 2024 10:04
Comment on lines +121 to +122
self.value = event.value_input
self.value_input = event.value_input
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about using param.discard_events for these two.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think that'll work since it'll suppress the subsequent change event as well since at that point the value won't changed. Events generally are processed before any value change and if we set it here then that rule is violated but I get that the values have to be set before the event.

@hoxbro
Copy link
Member Author
hoxbro commented Mar 29, 2024

I'm not entirely sure why test_active in panel/tests/chat/test_interface.py is failing after I sub-classed TextInput, can you see why @ahuang11?

@ahuang11
Copy link
Contributor
ahuang11 commented Mar 29, 2024

It's because ChatAreaInput inherits from TextAreaInput, which is now class TextAreaInput(_TextInputBase): instead of class TextAreaInput(TextInput).

However, the tests should check if it's ChatAreaInput not TextInput. I'll create a separate branch.

@hoxbro hoxbro marked this pull request as ready for review March 30, 2024 07:03
@philippjfr
Copy link
Member

I'm okay with the naming but changing the class hierarchy is technically an API change as you discovered in the chat interface. Maybe add a note about that to the changelog.

@hoxbro hoxbro requested a review from philippjfr May 7, 2024 08:52
@philippjfr philippjfr merged commit bec0f1d into main May 7, 2024
@philippjfr philippjfr deleted the enter_pressed_textinput branch May 7, 2024 09:05
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0