Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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/components/text-input-modal/TextInputModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class TextInputModal extends React.Component {
}

<input
ref={this.inputRef}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@SuchitraSwain this appears to be unnecessary/accidental addition that doesn't contribute to the fix.

Removed it.

onChange={this.onChange}
onKeyPress={this.onKeyPress}
value={this.state.value}
Expand Down
1 change: 1 addition & 0 deletions src/files/FilesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ const FilesPage = ({
failedPins: failedPins || [],
filesPathInfo,
selected,
modalOpen: modals.show !== null,
onSelect: (name, isSelected) => {
if (Array.isArray(name)) {
if (isSelected) {
Expand Down
11 changes: 8 additions & 3 deletions src/files/files-grid/files-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ interface FilesGridPropsConnected extends FilesGridProps {
onSelect: (fileName: string | string[], isSelected: boolean) => void
filesIsFetching: boolean
selected: string[]
modalOpen: boolean
}

const FilesGrid = ({
files, pins = [], remotePins = [], pendingPins = [], failedPins = [], filesPathInfo, t, onRemove, onRename, onNavigate, onAddFiles,
onMove, handleContextMenuClick, filesIsFetching, onSetPinning, onDismissFailedPin, selected = [], onSelect
onMove, handleContextMenuClick, filesIsFetching, onSetPinning, onDismissFailedPin, selected = [], onSelect, modalOpen = false
}: FilesGridPropsConnected) => {
const [focused, setFocused] = useState<string | null>(null)
const filesRefs = useRef<Record<string, HTMLDivElement>>({})
Expand Down Expand Up @@ -67,6 +68,11 @@ const FilesGrid = ({
}, [onSelect])

const keyHandler = useCallback((e: KeyboardEvent) => {
// Don't handle keyboard events when a modal is open
if (modalOpen) {
return
}

const focusedFile = focused == null ? null : files.find(el => el.name === focused)

gridRef.current?.focus?.()
Expand Down Expand Up @@ -148,8 +154,7 @@ const FilesGrid = ({
}
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [files, focused])
}, [files, focused, selected, onSelect, onRename, onRemove, onNavigate, handleSelect, modalOpen])

useEffect(() => {
if (filesIsFetching) return
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/grid-view.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,14 @@ test.describe('Files grid view', () => {
const folder = page.locator('.grid-file[title$="/"], .grid-file[data-type="directory"]').first()
const folderName = await folder.getAttribute('title')

// Press ArrowRight to focus the first item
await page.keyboard.press('ArrowRight')
// Wait for the focused element to appear
await page.waitForSelector('.grid-file.focused')
// Navigate to the folder (may need multiple presses)
for (let i = 0; i < 5; i++) {
const focusedItem = page.locator('.grid-file.focused')
await expect(focusedItem).toBeVisible()
const focusedTitle = await focusedItem.getAttribute('title') || ''

if (focusedTitle === folderName || focusedTitle.endsWith('/')) {
Expand Down
Loading