Skip to content
Draft
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
17 changes: 0 additions & 17 deletions app/NativeComponents/CommitDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,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;

/**
* The replies from the last frame, so a render only builds the replies that changed, as the Log does its rows.
*/
Expand Down Expand Up @@ -259,17 +253,6 @@ public function showEarlier(): void
$this->earlierShown = true;
}

/**
* 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->scrollKey++;
}

/**
* "› N replies" under the commit opens them in place, and "Hide replies" folds them away.
*/
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 @@ -5,7 +5,7 @@
@include('native.partials.live-stream-sheet')
@include('native.partials.stargazers-sheet')

<native:scroll-view native:key="thread-{{ $scrollKey }}" ref="thread-scroll" class="w-full flex-1 bg-theme-surface">
<native:scroll-view native:key="thread" ref="thread-scroll" class="w-full flex-1 bg-theme-surface">
<native:column ref="thread-page" class="w-full bg-theme-surface">
@if (! $commit && $error === null)
<native:column ref="loading-commit" class="w-full items-center py-16" a11y-label="Loading commit">
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,11 +1,10 @@
{{--
The reply bar's field on a commit's page (see partials/composer-plate). EDGE sends no focus event, so a press on the
field is how the page learns you're replying. The expand button is beside it rather than in it, so pressing it
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 (see partials/composer-plate). 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.
--}}
<native:column ref="reply-field" class="flex-1 ios:pl-4" @pressUp="replyTapped">
<native:column ref="reply-field" class="flex-1 ios:pl-4">
<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 @@ -67,22 +67,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-page'))->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 @@ -91,8 +82,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
Loading