Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8317426

focus-within is not always set correctly for table views

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • jfx21, jfx22
    • javafx
    • generic
    • generic

    Description

      ADDITIONAL SYSTEM INFORMATION :
      OpenJDK 21 + JavaFX 21

      A DESCRIPTION OF THE PROBLEM :
      When a TableView's selection is non-empty, its focus-within will remain true even after an unrelated Node in the same Scene has been focused. When a TableView's selection is empty, focus-within will become false when another Node is focused. It is not expected/intuitive for a TableView's focus-within behavior to depend on whether its selection is empty or not. I would expect the TableView's focus-within to behave consistently with any other type of Node: focus-within should always immediately become false whenever the Scene's focus moves elsewhere.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Clear instructions are provided in the README.md of the given github repo.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The TableView's focus-within should behave the same as if this were any other type of Node. More specifically: redirecting focus to the TextField should remove focus-within from the TableView regardless of whether the TableView's selection is empty.
      ACTUAL -
      Only when the TableView's selection is non-empty, its focus-within remains true even after an unrelated Node within the Scene has been focused. This results in unexpected/unintuitive behavior for usages of focus-within on the TableView. For example, in a different app I have a Pane containing a TableView in addition to other types of Nodes. I wanted to style that Pane differently to make it visually obvious whether anything inside it contains focus. Because of this bug I was not able to do that.

      ---------- BEGIN SOURCE ----------
      https://github.com/tcfurrer/javafx21-tables-focus-within-bug
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The only known workaround is: instead of using JavaFX's built-in focus-within property, implement an entirely independent custom alternative (as was done prior to the introduction of focus-within).

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              mstrauss Michael Strauß
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: