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

Fix issue #11938: Tab in empty text area field should focus the next field #12081

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

yeonissa
Copy link

This PR addresses the issue where pressing the Tab key in an empty text area should focus the next field, but it wasn't behaving as expected. The code change ensures that when the TextArea is empty, pressing the Tab key moves the focus to the next form field.

Closes #11938

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@koppor koppor added ui status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers labels Oct 25, 2024
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Too much obvious code comments.

I did not see any screenshots. Thus, reviewers need to run the tool. I think I can do it these days.

@@ -26,7 +28,20 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe
};

public EditorTextArea() {
// Call the constructor with an empty string.
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment - the code says it.

You can add a WHY to the comment. Why the empty string is passed. (If you know)

this("");

// Add an event filter to handle key press events
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment, the code says it.


// Add an event filter to handle key press events
this.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
// If the TAB key is pressed and the TextArea is empty
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment, the code says it.

this.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
// If the TAB key is pressed and the TextArea is empty
if (event.getCode() == KeyCode.TAB && this.getText().isEmpty()) {
// Move the focus to the next parent element (likely the next form field)
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment, the code says it.

// Move the focus to the next parent element (likely the next form field)
this.getParent().requestFocus();

// Consume the event to prevent further processing of the TAB key
Copy link
Member

Choose a reason for hiding this comment

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

Remove comment, the code says it.

@yeonissa
Copy link
Author

Hi @koppor,

Thank you for the feedback! I've now removed the obvious code comments as suggested.

@koppor koppor mentioned this pull request Oct 26, 2024
7 tasks
Copy link
Member

@koppor koppor left a comment

Choose a reason for hiding this comment

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

Did you try it out?

image

image

Reproduce:

  1. Create new library
  2. Create new entry
  3. Double click on entry
  4. Go to "Author" field
  5. Press Tab

@koppor koppor marked this pull request as draft October 26, 2024 20:32
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 26, 2024
@koppor
Copy link
Member

koppor commented Oct 26, 2024

You also need to add a CHANGELOG.md entry - as soon as you really fixed the issue.

@@ -27,6 +29,12 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe

public EditorTextArea() {
this("");
this.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
if (event.getCode() == KeyCode.TAB && this.getText() != null && this.getText().isEmpty()) {
Copy link
Member

Choose a reason for hiding this comment

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

You can use JabRefs StringUtil.isEmpty(this.getText())

@koppor koppor added the status: changes required Pull requests that are not yet complete label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: changes required Pull requests that are not yet complete ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tab in empty text area field should focus the next field
2 participants