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
1 change: 1 addition & 0 deletions src/Selecting.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ QtObject {
return
backend.folder.selectOnly(view.currentIndex)
anchor = view.currentIndex
view.positionViewAtIndex(view.currentIndex, ListView.Contain)
}

function click(index, modifiers) {
Expand Down
62 changes: 62 additions & 0 deletions tests/folio_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5787,6 +5787,68 @@ private slots:
QVERIFY(!FolderModel::toMap(FolderModel::Entry()).contains("peek"));
}

void folderKeyboardScrolls_data()
{
QTest::addColumn<QString>("viewType");
QTest::newRow("grid") << QString("FolderGrid");
QTest::newRow("list") << QString("FolderList");
QTest::newRow("columns") << QString("FolderColumns");
}

void folderKeyboardScrolls()
{
QFETCH(QString, viewType);
QTemporaryDir home;
QVERIFY(QDir(home.path()).mkdir("files"));
for (int i = 0; i < 80; ++i)
write(home.filePath(QString("files/file-%1.txt").arg(i, 2, 10, QLatin1Char('0'))), "x");
Backend backend(home.path());
backend.navigate(home.filePath("files"));
QTRY_COMPARE(backend.folder()->rowCount(), 80);
Theme theme(home.filePath("theme"));
FileOps fileOps;
Translator translator(home.filePath("language"), home.path());
Thumbnails thumbnails(home.filePath("cache"), {home.filePath("none")});
qmlRegisterType<FolderModel>("Folio", 1, 0, "FolderModel");
QQmlEngine engine;
engine.rootContext()->setContextProperty("backend", &backend);
engine.rootContext()->setContextProperty("theme", &theme);
engine.rootContext()->setContextProperty("fileOps", &fileOps);
engine.rootContext()->setContextProperty("translator", &translator);
engine.rootContext()->setContextProperty("plugins", QVariantMap{{"views", QVariantMap{}}});
engine.addImageProvider("thumb", new ThumbnailProvider(&thumbnails));
QQmlComponent component(&engine);
component.setData(QString(R"(
import QtQuick
Window {
width: 600; height: 480; visible: true
property alias cursor: folderView.currentIndex
%1 { id: folderView; anchors.fill: parent; Component.onCompleted: focusView() }
function cursorInView() {
const item = folderView.menuAnchor()
const y = item ? item.mapToItem(null, 0, 0).y : -1
return y >= 0 && y + item.height <= height
}
}
)").arg(viewType).toUtf8(), QUrl::fromLocalFile(sourceFolder() + "/KeyboardScrollTest.qml"));
std::unique_ptr<QObject> root(component.create());
QVERIFY2(root, qPrintable(component.errorString()));
auto *window = qobject_cast<QQuickWindow *>(root.get());
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
const auto cursorInView = [&] {
QVariant inView;
QMetaObject::invokeMethod(root.get(), "cursorInView", Q_RETURN_ARG(QVariant, inView));
return inView.toBool();
};
// Thirty presses take the cursor well past the fold in every view.
for (int i = 0; i < 30; ++i) {
QTest::keyClick(window, Qt::Key_Down);
QTRY_VERIFY(cursorInView());
}
QVERIFY(root->property("cursor").toInt() >= 29);
Comment on lines +5844 to +5849

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Broader input checks were removed

The shortened folderKeyboardScrolls test drops checks for Up, Shift+Down, clicks, wheel scrolling, and the selected items. It now checks only Down and cursor visibility. This is non-blocking, but it leaves broken range selection and unwanted scrolling less likely to be caught. Restore the removed checks alongside the visibility checks.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trim was deliberate: the maintainer asked for the smallest test that guards this fix. The removed steps (Up, Shift+Down, a click, wheel scrolling, clearing the cursor and the selected items) all passed on main without the fix, so they did not guard this change; they were regression coverage for other behaviour. The kept test fails in grid, list and columns with Selecting.qml reverted to main, and its index check fails if the first Down works but later ones are swallowed. If broader keyboard and selection coverage is wanted, it belongs in its own test rather than this one. Checked by Claude Opus 5.5 with a second opinion from Codex Medium and muse-wonder High.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right. I treated the omitted cases as a coverage loss without accounting for whether they fail without this fix. Since they pass on main, they don’t guard this regression; the retained test checks both visibility after each Down press and continued cursor advancement. I withdraw the recommendation to restore those checks. Broader keyboard and selection coverage belongs in a separate test.

}

void gridBandHitsTheTilesBothWays()
{
// The rubber band's hit areas sit where the grid put the tiles, also
Expand Down
Loading