Skip to content

Commit

Permalink
Merge pull request #5018 from mrflix/fix/date-time-tab-to-next
Browse files Browse the repository at this point in the history
Date field: fix tabbing behavior
  • Loading branch information
bastianallgeier authored Jan 26, 2023
2 parents 7dcacf7 + 7f83d4d commit af9abe4
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions panel/src/components/Forms/Input/DateInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ export default {
* c. cursor selection covers more than one part
* => select the last affected part
* d. cursor selection cover last part
* => tab should blur the input, focus on next tabbale element
* => tab should blur the input, focus on next tabable element
* e. cursor is at the end of the pattern
* => tab should blur the input, focus on next tabable element
*
* @param {Event} event
*/
Expand Down Expand Up @@ -322,8 +324,33 @@ export default {
this.selectNext(selection.index);
}
} else {
// select default part (step unit)
event.shiftKey ? this.selectLast() : this.selectFirst();
// nothing or no part fully selected
if (
this.$refs.input &&
this.$refs.input.selectionStart == selection.end + 1 &&
selection.index == this.pattern.parts.length - 1
) {
// cursor at the end of the pattern, jump out
return;
}
// more than one part selected, select last affected part
else if (
this.$refs.input &&
this.$refs.input.selectionEnd - 1 > selection.end
) {
const last = this.pattern.at(
this.$refs.input.selectionEnd,
this.$refs.input.selectionEnd
);
this.select(this.pattern.parts[last.index]);
}
// select part where the cursor is located
else {
this.select(this.pattern.parts[selection.index]);
}
}
event.preventDefault();
Expand Down

0 comments on commit af9abe4

Please sign in to comment.