Repository navigation
Respect per-task readonly in keyboard navigation shortcuts - #157
stepan-kuntso wants to merge 1 commit into
Conversation
The task row shortcuts passed the keyboard navigation node to gantt.isReadonly() instead of the task, so only the chart-wide config.readonly was checked. Enter opened the lightbox of a read-only task and saved changes, Ctrl+Enter added a subtask to it and Shift+Left/Right moved it.
|
@stepan-kuntso, |
|
Thank you. The pull request already contains a fix (one file, the |
|
Hi @stepan-kuntso! We've reviewed the change and accepted it. We also flagged a related gap - the '+' button in the grid row of a read-only task adds a subtask because it checks only the global readonly config. Since we accepted that the readonly task should get no new subtask, the same rule will apply to the "+" button - it will be hidden for read-only rows. As before, we'll apply the change to the internal repo together with regression tests. It will ship in Gantt 10.1, I'll close this PR with a link to the release. Thanks again for the contribution! |
|
Thank you, and good catch on the "+" button, hiding it for read-only |
What is broken
With the
keyboard_navigationplugin, a task that hasreadonly: true(orconfig.readonly_property) can still be changed from the keyboard, although the mouse respects the flag:gantt.$click.buttons.delete)How to reproduce
Reload the page before each step, so every step starts from the same tree.
Checked on
master(10.0.3) in Chrome on macOS.Cause
src/ext/keyboard_navigation/elements/task_row.js, the handlers forshift+right,shift+left,delete,enterandctrl+enter, callgantt.isReadonly(this).thisis the keyboard navigation node (TaskRoworTaskCell, which reuses these keys), not the task.gantt.isReadonly(item)readsitem[config.readonly_property]anditem[config.editable_property], which the node does not have, so onlyconfig.readonlyis checked.Fix
Pass the task id:
gantt.isReadonly(this.taskId).isReadonlyaccepts an id and looks the task up. BothTaskRowandTaskCellsetthis.taskId. Five identical one-line changes in one file.Side effect, consistent with the mouse: with
config.readonly = true, a task witheditable: true(config.editable_property) can now be opened with Enter, as with a double click. Before, the keys refused it.How to verify
I tested it manually in Chrome on macOS with the page above:
master: Enter on "Read-only task" opens the lightbox.gantt.config.readonly = true: Enter is refused on "Another task" and accepted on a task witheditable: true.npm run build,npm run lintandnpm run test(128 samples) pass.