diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..ad03d71 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Every text file is checked out with LF, on Windows too: Git for Windows otherwise makes them +# CRLF, and tests that compare files byte for byte, and what is built in, then differ by system. +* text=auto eol=lf diff --git a/CHANGELOG.md b/CHANGELOG.md index ccb2a2d..482d515 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ What changed in WittyModule, newest first. What changed before it had a repository of its own is in the [WittyMediaServer changelog](https://github.com/wittywilla/WittyMediaServer/blob/master/CHANGELOG.md). +## 0.5.5 + +- SDUI core synced from the server (a focusable list's rows stay focus stops; a List's rows carry their items' buttons). Text files are checked out with LF, and module-kit gives every module a .gitattributes that says so (#7). + ## 0.5.4 - **Module API 5 only.** `MinAPI` is 5: `check` refuses a manifest of API 3 or 4, and `Supports` says to install a version built for module API 5. `SDUIFromAPI` and `IntegrationFromAPI` are gone: every helper, program and web module carries `sdui.json` and `integration.json`. This module's own manifest says API 5. Specification 5.0. diff --git a/kit/module-kit.sh b/kit/module-kit.sh index 4e3beab..2f36b67 100755 --- a/kit/module-kit.sh +++ b/kit/module-kit.sh @@ -214,6 +214,7 @@ To take a version back, run the *withdraw* workflow from the *Actions* tab. It a esac render "$templates/dependabot.yml" "$dir/.github/dependabot.yml" [ -f "$dir/.gitignore" ] || cp "$templates/gitignore" "$dir/.gitignore" + [ -f "$dir/.gitattributes" ] || cp "$templates/gitattributes" "$dir/.gitattributes" web_package "$dir" case " $words " in *" webpart "*) sdui_kit "$dir" ;; diff --git a/kit/templates/gitattributes b/kit/templates/gitattributes new file mode 100644 index 0000000..ad03d71 --- /dev/null +++ b/kit/templates/gitattributes @@ -0,0 +1,3 @@ +# Every text file is checked out with LF, on Windows too: Git for Windows otherwise makes them +# CRLF, and tests that compare files byte for byte, and what is built in, then differ by system. +* text=auto eol=lf diff --git a/module.json b/module.json index 2743bed..3912bf5 100644 --- a/module.json +++ b/module.json @@ -1,7 +1,7 @@ { "id": "wittymodule", "name": "WittyModule", - "version": "0.5.4", + "version": "0.5.5", "license": "AGPL-3.0-or-later", "repo": "wittywilla/WittyModule", "delivery": "library", diff --git a/sdui/core/focus.go b/sdui/core/focus.go index 480e511..2d369ee 100644 --- a/sdui/core/focus.go +++ b/sdui/core/focus.go @@ -25,7 +25,9 @@ func Focusable(n *Node, inHero bool) bool { if c, ok := n.Props["control"].(*Control); ok && c != nil { return !c.Disabled || n.Action != nil } - return n.Action != nil + // A row of a focusable list stays a stop without an action, so focus isn't lost when a + // refresh sends it without one for a while (Scan for changes while a scan runs). + return n.Action != nil || n.Props["focusable"] == true case "Hero": return len(n.Children) > 0 case "DetailHeader": @@ -50,14 +52,17 @@ func focusGroup(n *Node) bool { // 1. a SearchBox with autofocus; // 2. else the page's DetailHeader; // 3. else the first focusable node that isn't a Tab, a FilterBar or a -// SearchBox: the content, not the controls above it; +// SearchBox: the content, not the controls above it. A row of a +// focusable List that has no action (a line that only says how things +// stand, such as "Last scanned") is passed over for the next one; // 4. else the first focusable node. func stampFocus(root *Node) { order := 0 var first, content, header, search *Node var walk func(n *Node, group string, inHero bool) var stamp func(n *Node, group string, inHero bool) - inDock := false // the Dock's buttons are controls, not content: focus doesn't start there + inDock := false // the Dock's buttons are controls, not content: focus doesn't start there + passive := false // in a focusable List, whose rows without an action are stops but not starts walk = func(n *Node, group string, inHero bool) { if n.Type == "Dock" { inDock = true @@ -82,9 +87,12 @@ func stampFocus(root *Node) { if focusGroup(n) { group = n.ID } + was := passive + passive = listLike(n.Type) && n.Props["focusable"] == true for i := range n.Children { walk(&n.Children[i], group, inHero || n.Type == "Hero") } + passive = was } stamp = func(n *Node, group string, inHero bool) { n.Focus = nil @@ -106,7 +114,7 @@ func stampFocus(root *Node) { } fallthrough default: - if content == nil && !inDock { + if content == nil && !inDock && !(passive && n.Action == nil) { content = n } } diff --git a/sdui/core/render.go b/sdui/core/render.go index eed4624..7c18c19 100644 --- a/sdui/core/render.go +++ b/sdui/core/render.go @@ -1197,6 +1197,9 @@ func (r *renderer) collectionPage(n *Node, in instance, offset, limit int, allow row.Props["number"] = strconv.Itoa(num) } } + if propBool(p, "focusable", false) { + row.Props["focusable"] = true // a stop even while it has no action (a scan's choices while it runs) + } n.Children = append(n.Children, row) continue } @@ -1292,6 +1295,10 @@ func (r *renderer) listItem(parent string, it *Item) Node { if c := cleanControl(it.Control); c != nil { n.Props["control"] = c } + // The item's own buttons (a friend's Invite, a room's Join and Leave), as a card carries them. + if acts := cleanActions(it.Actions); len(acts) > 0 { + n.Props["actions"] = acts + } switch { case it.Action != nil: n.Action = it.Action