feat: Intra-line double link interaction
This commit is contained in:
@@ -79,16 +79,12 @@ export const DoubleLinkMenuContainer = (
|
|||||||
if (types && ['ArrowUp', 'ArrowDown'].includes(event.code)) {
|
if (types && ['ArrowUp', 'ArrowDown'].includes(event.code)) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const isUpkey = event.code === 'ArrowUp';
|
const isUpkey = event.code === 'ArrowUp';
|
||||||
const indexBound = isUpkey ? types.length - 1 : 0;
|
|
||||||
if (!currentItem && types.length) {
|
if (!currentItem && types.length) {
|
||||||
setCurrentItem(types[indexBound]);
|
setCurrentItem(types[isUpkey ? types.length - 1 : 0]);
|
||||||
}
|
}
|
||||||
if (currentItem) {
|
if (currentItem) {
|
||||||
const idx = types.indexOf(currentItem);
|
const idx = types.indexOf(currentItem);
|
||||||
const needChange = isUpkey
|
if (isUpkey ? idx > 0 : idx < types.length - 1) {
|
||||||
? idx > indexBound
|
|
||||||
: idx < indexBound;
|
|
||||||
if (needChange) {
|
|
||||||
setNeedCheckIntoView(true);
|
setNeedCheckIntoView(true);
|
||||||
setCurrentItem(types[isUpkey ? idx - 1 : idx + 1]);
|
setCurrentItem(types[isUpkey ? idx - 1 : idx + 1]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user