Commit Graph

1192 Commits

Author SHA1 Message Date
Rodrigo Girão Serrão
a6ee867ee3 Fix tests. 2023-05-16 11:39:38 +01:00
Rodrigo Girão Serrão
b592ac077a AUTO_FOCUS targets first focusable widget.
Related issues: #2578.
2023-05-16 11:27:24 +01:00
Rodrigo Girão Serrão
fe7812d94d Add regression test for #2563. 2023-05-15 13:24:48 +01:00
Rodrigo Girão Serrão
0b6e3b3040 Merge branch 'main' into auto-focus 2023-05-15 10:41:15 +01:00
Rodrigo Girão Serrão
c967661699 Merge branch 'main' into move-child-no-op 2023-05-15 10:31:43 +01:00
Will McGugan
d266e3685f snapshot update (#2555) 2023-05-12 18:57:53 +02:00
Will McGugan
c2e7b619f1 Revert "virtual size and docks"
This reverts commit 9a134b4920.
2023-05-12 15:53:47 +02:00
Will McGugan
9a134b4920 virtual size and docks 2023-05-12 15:36:49 +02:00
Dave Pearson
2d75ca0d77 Merge pull request #2536 from davep/expand-tree-expand-messages
Ensure that `TreeNode` messages are posted when via-API changes are made
2023-05-10 14:18:24 +01:00
Rodrigo Girão Serrão
8dd627b0f4 Merge branch 'main' into sub-title-str 2023-05-10 13:10:48 +01:00
Dave Pearson
28be54d10d Merge branch 'main' into expand-tree-expand-messages 2023-05-10 10:12:58 +01:00
Dave Pearson
f19f46bba0 Merge pull request #2519 from davep/cygnus-x-1
Fix for `resolve_fraction_unit` zero division error (#2502)
2023-05-10 10:10:55 +01:00
Dave Pearson
c7fc66fa6c Ensure that TreeNode messages are posted when via-API changes are made
Until now the Tree.NodeExpanded and Tree.NodeCollapsed messages were only
sent out when changes were made to the tree by user interaction. This meant
that if any changes were made with the TreeNode expand, expand_all,
collapse, collapse_all, toggle or toggle_all API calls no messages would be
sent.

This PR corrects this.

The work here is, in part, required for #2456 (DirectoryTree lazy-loads
directory information on node expansion so if someone is expanding nodes
under code control the DirectoryTree never gets to know that it should load
a directory's content) and will build on #1644, essentially adding a missing
aspect to the latter PR.
2023-05-10 09:24:07 +01:00
Rodrigo Girão Serrão
e8baf52bdd Allow setting (sub)title of any type.
Related issues: #2521.
2023-05-09 16:56:56 +01:00
Rodrigo Girão Serrão
3245eb38bb Make auto-focus a class var.
Related comments: https://github.com/Textualize/textual/pull/2527\#discussion_r1188776849
2023-05-09 16:44:37 +01:00
Rodrigo Girão Serrão
eafe6b1786 Moving child before/after self is a no-op.
Related issues: #1743.
2023-05-09 15:57:23 +01:00
Dave Pearson
8855471125 Merge pull request #2522 from davep/move-widget-enhanced-testing
Make the widget moving tests more granular and add more tests
2023-05-09 15:07:59 +01:00
Rodrigo Girão Serrão
ed4d811451 Add tests for Screen auto focus.
Related issues: #2457.
2023-05-09 14:55:18 +01:00
Dave Pearson
a0558e87d8 Merge branch 'main' into cygnus-x-1 2023-05-09 13:38:16 +01:00
Dave Pearson
ee70713002 Simplify the resolver zero division bug unit test 2023-05-09 13:35:55 +01:00
Dave Pearson
d3de6d1587 Make the widget moving tests more granular and add more tests
Adds two (currently xfail) tests to illustrate #1743
2023-05-09 11:19:00 +01:00
Dave Pearson
a77dbf4bee Tentative fix for resolve_fraction_unit ZeroDivision error
I'll admit to not really following what the code does, so will really need
someone with a better understanding of the aim of this code to look over the
proposed fix; but based on a bunch of runs and hand-debugging, this seems to
do the job.

This passes all existing tests and also removes the reported error.

On the other hand I'm not confident that I'm *not* just masking an
underlying issue with this function.
2023-05-09 10:38:09 +01:00
Dave Pearson
a5cc96cbc7 Make a pass of the #2502 test a fail
If/when I get this actually passing, I want the test to appear to fail so I
know things have changed for the better.

This makes sense, trust me.
2023-05-09 09:44:51 +01:00
Dave Pearson
052ec83b7a Make the test as small as possible 2023-05-09 09:44:30 +01:00
Dave Pearson
089dce1b41 Add a unit test for #2502
Currently marked as xfail, but this gets it down to the most basic level.
2023-05-09 09:39:12 +01:00
Rodrigo Girão Serrão
855c90d4f0 Extend @on decorator to filter matchable attributes (#2498)
* Add tests for #2484.

* Implement @on extension.

[skip ci]
Related issues: #2484.

* Changelog.

* Add missing @on test.

* Remove debug prints.

* Document changes.

* Update tests.

Test now fully works, as of #2490.

* Cache parsed selectors.

* Streamline exit condition.

* Fix typing.

* More succint wording.

* Document 'on' kwargs.

* Update src/textual/_on.py

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Update docs/guide/events.md

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Change 'on' API.

* Remove example code.

* Address feedback.

* Update src/textual/_on.py

Co-authored-by: Will McGugan <willmcgugan@gmail.com>

* Address review feedback.

* Fix #2499.

* don't require control to be manually specified

* update docstring

* deleted words

---------

Co-authored-by: Will McGugan <willmcgugan@gmail.com>
2023-05-08 17:30:07 +01:00
Will McGugan
7db7139bb8 Select widget (#2501)
* overlay rule

* select WIP

* select control, made binding description optional

* changelog

* style tweak

* Added constrain

* changelog

* test fix

* drop markup, tidy

* tidy

* select namespace

* tests

* docs

* Added changed event

* changelog

* expanded

* tests and snapshits

* examples and docs

* simplify

* update reactive attributes

* type fix

* docstrings

* allow renderables

* superfluous init

* typing fix

* optimization

* revert optimizations

* fixed words

* changelog

* docstrings

* don't need this

* changelog

* comment

* Update docs/widgets/select.md

Co-authored-by: Dave Pearson <davep@davep.org>

* review changes

* review updates

---------

Co-authored-by: Dave Pearson <davep@davep.org>
2023-05-08 10:55:39 +01:00
Dave Pearson
c2a19bd632 Merge pull request #2510 from davep/chainsaw
Add the ability to remove nodes from a `Tree`
2023-05-08 10:51:44 +01:00
Dave Pearson
0bb0f4d179 Merge pull request #2508 from davep/add-options
Add `add_options` to `OptionList`
2023-05-08 10:51:15 +01:00
Rodrigo Girão Serrão
819b2f1eb3 Add DataTable.move_cursor (#2479)
* Add 'DataTable.move_cursor'.

Related issues: #2472.

* Fix #2471.

* Simplify cursor changes.

* Address review feedback.

Related comments: https://github.com/Textualize/textual/pull/2479\#discussion_r1185016002
2023-05-08 10:44:34 +01:00
Dave Pearson
745d595d4a Add unit tests for the new node removal methods
See #2462.
2023-05-08 09:55:32 +01:00
Dave Pearson
84ddd09223 Add extra snapshit tests
This tests the three main ways of making an option list, and ensures they
all turn out the same.
2023-05-07 20:26:12 +01:00
Dave Pearson
8be87d5931 Merge branch 'main' into add-options 2023-05-07 18:06:57 +01:00
Dave Pearson
010356a23e Allow zero items to be passed to add_options and do zero work 2023-05-07 18:01:56 +01:00
Dave Pearson
b44983e8d4 Add an add_options method to the OptionList
In doing so, pretty much make the add_option code into the add_options code,
and then just have add_option call add_options.

See #2507.
2023-05-07 17:56:02 +01:00
Dave Pearson
6139c95f3a Test that the event aliases are actually the same reference
I thought I thought I wanted what I thought but now I think about it I think
I thought wrong and now I think better.
2023-05-04 16:43:20 +01:00
Dave Pearson
8b36d29e74 Add a test for a radio set getting focus when a button gets clicked 2023-05-04 16:22:39 +01:00
Dave Pearson
19f4f64d96 Add tests for selection navigation in a radioset with no buttons pressed 2023-05-04 15:39:33 +01:00
Dave Pearson
e7d3b94334 Test that radioset wraps around when going off the bottom 2023-05-04 15:25:33 +01:00
Dave Pearson
b1443c0162 Test that radioset wraps around when going off the top 2023-05-04 15:22:30 +01:00
Dave Pearson
2113f415a0 Add a test that toggling a pressed radio button has no effect 2023-05-04 15:17:52 +01:00
Dave Pearson
b7cdbb0baa Test to ensure that Changed.control is Control.checkbox 2023-05-04 15:12:15 +01:00
Dave Pearson
0b4d7fb091 Test to ensure that Changed.control is Control.radio_button 2023-05-04 15:10:45 +01:00
Rodrigo Girão Serrão
3728555fbd Scroll cursor into view. (#2464)
* Scroll cursor into view.

Related issues: #2459.

* Add regression test.

* Update changelog.
2023-05-03 13:57:04 +01:00
Will McGugan
41dbc66b23 optimize focus (#2460)
* optimize focus

* immediate call

* update previews

* snapshot
2023-05-03 11:48:56 +01:00
Will McGugan
91a9d570a4 On decorator (#2453)
* Add on decorator

* decorator code

* docs for on decorator

* Examples

* test errors

* simplify listing

* words

* changelog

* Update docs/guide/events.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/guide/events.md

Co-authored-by: Dave Pearson <davep@davep.org>

* Update docs/examples/events/on_decorator.css

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* Update docs/guide/events.md

Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>

* rewording

* comment

* clarification

* Added note

---------

Co-authored-by: Dave Pearson <davep@davep.org>
Co-authored-by: Rodrigo Girão Serrão <5621605+rodrigogiraoserrao@users.noreply.github.com>
2023-05-02 16:17:40 +01:00
Dave Pearson
2ad3903d43 Remove the bytewise diffing of failed snapshots
In doing so this removes the file similarity value, and as such the key that
the failure report was sorted on. This was done because, given how many
snapshot tests we have now, if lots failed, it would take a long time (often
many minutes) to compile the report.

The report is now sorted on the test name.

Now, no matter how many snapshots fail, the report should be produced pretty
much instantly.
2023-05-02 13:47:18 +01:00
Dave Pearson
27ca4969a8 Add tests for styles that have "sub-styles" and !important
This is a series of tests for checking styles that have sub-styles, or
sub-parts, or whatever the correct name would be; the testing being that if
!important is applied to the whole, that it works.

Starting with #2420 it became apparent that this didn't work as intended,
and once that work started it became obvious that it affected more than just
border.

So these tests test all of the styles that can be specified as a single
whole, or as a set of parts (sides, directions, etc).
2023-05-02 09:36:08 +01:00
Will McGugan
83b1fcc102 raise attribute error (#2443)
* raise attribute error

* fix compute defaults
2023-05-01 16:57:40 +01:00
Will McGugan
20a1612361 Invalid pseudo selectors (#2445)
* token error

* error on bad pseudo selectors
2023-05-01 16:22:35 +01:00