-
-
Notifications
You must be signed in to change notification settings - Fork 317
Scene widget: allow ordering the scenes list #2945
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
Open
Pierre-Gilles
wants to merge
2
commits into
master
Choose a base branch
from
claude/scene-widget-order
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
front/src/components/drag-and-drop/SceneListWithDragAndDrop.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { DndProvider, useDrag, useDrop } from 'react-dnd'; | ||
| import { useRef } from 'preact/hooks'; | ||
| import cx from 'classnames'; | ||
| import style from './style.css'; | ||
| import { getDragAndDropBackend } from '../../utils/dragAndDropBackend'; | ||
|
|
||
| const SCENE_TYPE = 'SCENE_TYPE'; | ||
|
|
||
| // We use Preact Hooks here because the library react-dnd needs that | ||
| // We do not recommend using them in other places in Gladys front | ||
| const SceneRow = ({ selectedSceneOption, moveScene, index }) => { | ||
| const ref = useRef(null); | ||
| const [{ isDragging }, drag, preview] = useDrag(() => ({ | ||
| type: SCENE_TYPE, | ||
| item: () => { | ||
| return { index }; | ||
| }, | ||
| collect: monitor => ({ | ||
| isDragging: !!monitor.isDragging() | ||
| }) | ||
| })); | ||
| const [{ isActive }, drop] = useDrop({ | ||
| accept: SCENE_TYPE, | ||
| collect: monitor => ({ | ||
| isActive: monitor.canDrop() && monitor.isOver() | ||
| }), | ||
| drop(item) { | ||
| if (!ref.current) { | ||
| return; | ||
| } | ||
| moveScene(item.index, index); | ||
| } | ||
| }); | ||
| preview(drop(ref)); | ||
|
|
||
| return ( | ||
| <div class="mb-1"> | ||
| <div | ||
| class={cx('input-group', style.sceneListDragAndDrop, { | ||
| [style.sceneListDragAndDropDragging]: isDragging | ||
| })} | ||
| ref={ref} | ||
| > | ||
| <div class="input-group-prepend" ref={drag}> | ||
| <span class="input-group-text fe fe-list" /> | ||
| </div> | ||
| <div | ||
| class={cx('form-control', style.sceneListDragAndDropLabel, { | ||
| [style.sceneListDragAndDropActive]: isActive | ||
| })} | ||
| > | ||
| {selectedSceneOption.label} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const { backend: dragAndDropBackend, options: dragAndDropBackendOptions } = getDragAndDropBackend(); | ||
|
|
||
| const SceneListWithDragAndDrop = ({ selectedSceneOptions, moveScene }) => ( | ||
| <DndProvider backend={dragAndDropBackend} options={dragAndDropBackendOptions}> | ||
| {selectedSceneOptions.map((selectedSceneOption, index) => ( | ||
| <SceneRow selectedSceneOption={selectedSceneOption} index={index} moveScene={moveScene} /> | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| ))} | ||
| </DndProvider> | ||
| ); | ||
|
|
||
| export { SceneListWithDragAndDrop }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: GladysAssistant/Gladys
Length of output: 8055
🏁 Script executed:
Repository: GladysAssistant/Gladys
Length of output: 21328
🏁 Script executed:
Repository: GladysAssistant/Gladys
Length of output: 433
🏁 Script executed:
Repository: GladysAssistant/Gladys
Length of output: 421
Add keyboard controls for scene reordering.
When custom order is enabled, render focusable Move up and Move down buttons for each scene with accessible names and disabled boundary states. Keep drag-and-drop for pointer input.
🤖 Prompt for AI Agents
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.
Not changed, on purpose.
Keyboard reordering controls would be a genuine improvement, but they are a new UI affordance rather than a fix to this PR: this list is a copy of the
DeviceListWithDragAndDroppattern the devices widget has used for years, with the same drag handle and the same lack of keyboard controls. Adding Move up / Move down buttons to the scene list only would leave the two widgets inconsistent, and doing it in both is a change of its own — with its own translation keys and styles — well beyond "let the scenes be ordered".Worth opening as a separate accessibility issue covering both drag & drop lists.
Generated by Claude Code
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.
@Pierre-Gilles, agreed. The keyboard reordering gap affects bothSceneListWithDragAndDropandDeviceListWithDragAndDrop. Changing only the new scene list would make the widget interactions inconsistent.This PR can keep the established drag-and-drop pattern. A separate accessibility issue should cover keyboard reordering, shared interaction behavior, translations, and styles for both lists.
Would you like me to open that follow-up issue?
✏️ Learnings added
🧠 Learnings used
You are interacting with an AI system.