Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions app/NativeComponents/CommitDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,6 @@ class CommitDetail extends NativeComponent
*/
public bool $focusReply = false;

/**
* Keys the page's scroll view. EDGE can't scroll it from PHP, so a new key
* mounts it again at the top.
*/
public int $scrollKey = 0;

/**
* Which of the scroll view's rows it brings into view: the commit's, once tapping another commit in the tree
* moved the page to it (see refocus()), or the reply you just sent (see scrollToRow()). Null until one of those,
Expand Down Expand Up @@ -407,18 +401,6 @@ public function showEarlier(): void
$this->countAncestorReplies();
}

/**
* Tapping into the reply bar brings the commit being answered back up, under
* its parent: the earlier commits fold away again and the page starts over
* from the top.
*/
public function replyTapped(): void
{
$this->earlierShown = false;
$this->scrollTarget = null;
$this->scrollKey++;
}

/**
* A commit in the tree this page shows moves the page to it, rather than
* pushing another commit page (see refocus()). Anything else opens its page.
Expand Down
2 changes: 1 addition & 1 deletion resources/views/native/commit-detail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
is keyed commit-<id>, as the commits above it are. These need NativePHP/mobile-air#736 and
NativePHP/mobile-ui#225; without them the move jumps and a repeat of the same row doesn't scroll.
--}}
<native:scroll-view native:key="thread-{{ $scrollKey }}" ref="thread-scroll" class="w-full h-full bg-theme-surface" :auto-scroll-to="$scrollTarget" :auto-scroll-token="$scrollRequest" auto-scroll-animated animate-layout>
<native:scroll-view native:key="thread" ref="thread-scroll" class="w-full h-full bg-theme-surface" :auto-scroll-to="$scrollTarget" :auto-scroll-token="$scrollRequest" auto-scroll-animated animate-layout>
@if (! $commit && $error === null)
<native:column ref="loading-commit" class="w-full items-center py-16" a11y-label="Loading commit">
<native:activity-indicator />
Expand Down
7 changes: 3 additions & 4 deletions resources/views/native/partials/reply-field.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{{--
The reply bar's field on a commit's page, across the top of partials/composer-box. EDGE sends no focus event, so a
press on the field is how the page learns you're replying. The tools are in the row under it, so pressing them
doesn't count. Where the caret is goes to the page as it moves, for the "@" suggestions above the bar (see
The reply bar's field on a commit's page, across the top of partials/composer-box. Tapping into it leaves the
page where it is. Where the caret is goes to the page as it moves, for the "@" suggestions above the bar (see
SuggestsMentions). It keeps the keyboard up through presses elsewhere on the page (keep-focus), as the Remotes
field does, so picking someone to mention leaves you typing after them. It grows with the reply to five lines and
then scrolls, sized by the field itself, not by the page.
--}}
<native:column native:key="reply-field" ref="reply-field" class="flex-1" @pressUp="replyTapped">
<native:column native:key="reply-field" ref="reply-field" class="flex-1">
<native:bare-text-input
ref="reply-input"
class="w-full py-2 text-theme-ink"
Expand Down
19 changes: 5 additions & 14 deletions tests/Feature/Screens/CommitDetailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,22 +73,13 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []):
->assertSee('1 reply');
});

it('brings the commit back up under its parent when you tap into the reply bar', function () {
it('leaves the page where it is when you tap into the reply bar', function () {
fakeThread(['replies_count' => 1], replies: [replyJson(['id' => 'r1', 'parent_id' => 'c2', 'body' => 'First reply', 'author' => userJson(['handle' => 'grace', 'name' => 'Grace'])])]);

$screen = Native::visit('/log/commits/c2')->tap('earlier-commits')->assertSee('The root commit');
$before = nodeByRef($screen, 'thread-scroll')['id'];

// EDGE can't scroll from PHP, so the older ancestors fold away and the scroll view mounts again at the top.
$screen->pressUp('reply-field')
->assertSet('earlierShown', false)
->assertSet('scrollKey', 1)
->assertSee('1 earlier commit')
->assertSee('The parent commit')
->assertDontSee('The root commit');

expect(childRefs($screen, 'thread-scroll'))->toBe(['earlier-commits', 'commit-c1', 'focused-commit', 'reply-bar-clearance'])
->and(nodeByRef($screen, 'thread-scroll')['id'])->not->toBe($before);
// The field has nothing to do on a press: the earlier commits stay open and the scroll view isn't mounted again.
expect(nodeByRef($screen, 'reply-field')['props']['on_press_up'] ?? null)->toBeNull();
});

it('keeps the reply field the same view while the thread above it changes, so the keyboard stays up', function () {
Expand All @@ -97,8 +88,8 @@ function fakeThread(array $commit = [], array $replies = [], array $extra = []):
$screen = Native::visit('/log/commits/c2')->tap('earlier-commits')->input('reply-input', 'Nice');
$field = idsDownTo($screen->tree(), 'reply-input');

// Tapping into the bar, which folds the earlier commits away above it.
$screen->pressUp('reply-field')->assertDontSee('The root commit');
// The earlier commits folding away above it.
$screen->set('earlierShown', false)->assertDontSee('The root commit');
expect(idsDownTo($screen->tree(), 'reply-input'))->toBe($field);

// More of the thread drawn above it.
Expand Down
3 changes: 0 additions & 3 deletions tests/Feature/Screens/PartialFramesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,9 @@ function servePartialFramePage(array $routes, string $starred): void
$steps = [
'the earlier commits shown' => fn () => $screen->call('showEarlier'),
'the replies opened' => fn () => $screen->call('toggleReplies'),
// The scroll view mounts again at the top, under a new key.
'a tap into the reply field' => fn () => $screen->call('replyTapped'),
'a letter typed' => fn () => $screen->set('reply', 'N'),
'another' => fn () => $screen->set('reply', 'Ni'),
'the replies hidden' => fn () => $screen->call('toggleReplies'),
'the reply field tapped again' => fn () => $screen->call('replyTapped'),
'the replies opened again' => fn () => $screen->call('toggleReplies'),
// The page moves to a commit above, keeping its scroll view and the commits it shows, and back down.
'the page moved up' => fn () => $screen->call('openCommit', 'c1')->assertSet('id', 'c1'),
Expand Down
Loading