-
Notifications
You must be signed in to change notification settings - Fork 1
Allow drag and drop onto home page #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,8 +6,84 @@ import ografLogoUrl from '../assets/ograf_logo_colour_draft.svg' | |||||||||||||||||||||||||||||||||||||||||||||||||||
| import { serviceWorkerHandler } from '../ServiceWorkerHandler' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| export function InitialView({ onGraphicsFolder }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [isDragging, setIsDragging] = React.useState(false) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const [error, setError] = React.useState(null) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| const handleFolderSelect = React.useCallback( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| async (dirHandle) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| fileHandler.dirHandle = dirHandle | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onGraphicsFolder({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| graphicsList: await fileHandler.listGraphics(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| graphicsFolderName: fileHandler.dirHandle.name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error(err) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| setError(err.message) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| setError(err.message) | |
| setError(err?.message || String(err)) |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handleDragLeave implementation will trigger when dragging over child elements within the drop zone, causing the dragging visual feedback to flicker. This happens because dragLeave fires when entering child elements like the heading, paragraphs, or button.
To fix this, you need to track if the drag actually left the container by checking the relatedTarget or by using a reference counter pattern. One common approach is to only reset isDragging to false when the related target is not a descendant of the drop zone container.
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drag and drop zone lacks ARIA attributes to make it accessible to screen readers and assistive technologies. Users who rely on keyboard navigation or screen readers won't be aware that this area accepts folder drops.
Consider adding appropriate ARIA attributes such as 'role="region"' and 'aria-label' to describe the drop zone functionality. You might also want to add 'aria-live' to announce when the dragging state changes.
| onDrop={handleDrop} | |
| > | |
| onDrop={handleDrop} | |
| role="region" | |
| aria-label="Graphics folder drop zone. Drag and drop a folder here or use the button below." | |
| tabIndex={0} | |
| > | |
| <div | |
| aria-live="polite" | |
| style={{ | |
| position: 'absolute', | |
| width: '1px', | |
| height: '1px', | |
| margin: '-1px', | |
| border: 0, | |
| padding: 0, | |
| clip: 'rect(0 0 0 0)', | |
| overflow: 'hidden', | |
| whiteSpace: 'nowrap', | |
| }} | |
| > | |
| {isDragging | |
| ? 'Folder detected over drop zone. Release to load graphics.' | |
| : 'Drag and drop a graphics folder onto this region to load graphics.'} | |
| </div> |
Copilot
AI
Feb 6, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message access pattern 'err.message' may not be safe for all error types. If err is null, undefined, or doesn't have a message property, this could fail.
Consider using a more defensive pattern like 'err?.message || String(err)' to ensure an error message is always available, similar to the fallback used in the handleDrop function at line 73.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting 'pointer-events: none' on the content and then re-enabling it for specific elements is a fragile pattern. If any new interactive elements (inputs, selects, other buttons, etc.) are added to the initial-hero-content in the future, they will be non-interactive unless explicitly given 'pointer-events: all'.
Consider a more maintainable approach, such as handling drag events at the container level and using event.target checks, or using a more specific selector for elements that should not block drag events.