Doubleclick in Table and Tree with data==None triggers IndexError
- Dominant language
- Python
- Stars
- 5.4k
- Forks
- 827
- Avg merge
- 9h 45m
- Merged PRs (30d)
- 58
Description
### Describe the bug
doubleclick in table with data==None triggers IndexError
example below results in error below
this might be by design, but since None is an acceptable value for data per the documentation, and it makes perfect sense to have an empty table in an application (mine is empty until the user triggers a db query), this behavior is unexpected to me
not a disaster - why would a user click there anyway If there is no data - but also not great since it crashes the application
```
Traceback (most recent call last):
File ".../.venv/lib/python3.14/site-packages/rubicon/objc/api.py", line 412, in __call__
result = self.py_method(py_self, *args)
File ".../.venv/lib/python3.14/site-packages/toga_cocoa/widgets/table.py", line 127, in onDoubleClick_
clicked = self.interface.data[self.clickedRow]
File ".../.venv/lib/python3.14/site-packages/toga/sources/list_source.py", line 135, in __getitem__
return self._data[index]
IndexError: list index out of range
```
### Steps to reproduce
```
import toga
class MyApp(toga.App):
def startup(self):
self.main_window = toga.MainWindow()
self.main_window.content = toga.Table(
headings=["Name", "Age"],
# data=[
# ("Arthur Dent", 42),
# ("Ford Prefect", 37),
# ("Tricia McMillan", 38),
# ],
data=None,
multiple_select=False,
)
self.main_window.show()
if __name__ == '__main__':
app = MyApp("Realistic App", "org.beeware.realistic")
app.main_loop()
```
### Expected behavior
no exception
### Screenshots
_No response_
### Environment
macOS 24.6.0
Python 3.14.0 (main, Oct 7 2025, 09:34:52) [Clang 17.0.0 (clang-1700.0.13.3)] on darwin
Toga: toga-0.5.2
### Logs
```
```
### Additional context
_No response_
Contributor guide
Research direction
Start with toga_cocoa/widgets/table.py at onDoubleClick_ and toga/sources/list_source.py at __getitem__, then run the supplied empty-data reproduction. Check the corresponding table and tree double-click behavior; done means clicking an empty widget raises no IndexError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100