pl-fe: improve keyboard navigation
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
195a027294
commit
053520de2e
8 changed files with 42 additions and 26 deletions
|
@ -160,7 +160,7 @@
|
||||||
"react-sparklines": "^1.7.0",
|
"react-sparklines": "^1.7.0",
|
||||||
"react-sticky-box": "^2.0.0",
|
"react-sticky-box": "^2.0.0",
|
||||||
"react-swipeable-views": "^0.14.0",
|
"react-swipeable-views": "^0.14.0",
|
||||||
"react-virtuoso": "^4.10.2",
|
"react-virtuoso": "^4.10.4",
|
||||||
"redux": "^5.0.0",
|
"redux": "^5.0.0",
|
||||||
"redux-immutable": "^4.0.0",
|
"redux-immutable": "^4.0.0",
|
||||||
"redux-thunk": "^3.1.0",
|
"redux-thunk": "^3.1.0",
|
||||||
|
|
|
@ -92,12 +92,16 @@ const StatusList: React.FC<IStatusList> = ({
|
||||||
}, 300, { leading: true }), [onLoadMore, lastStatusId, statusIds.last()]);
|
}, 300, { leading: true }), [onLoadMore, lastStatusId, statusIds.last()]);
|
||||||
|
|
||||||
const selectChild = (index: number) => {
|
const selectChild = (index: number) => {
|
||||||
|
const selector = `#status-list [data-index="${index}"] .focusable`;
|
||||||
|
const element = document.querySelector<HTMLDivElement>(selector);
|
||||||
|
|
||||||
|
if (element) element.focus();
|
||||||
|
|
||||||
node.current?.scrollIntoView({
|
node.current?.scrollIntoView({
|
||||||
index,
|
index,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
done: () => {
|
done: () => {
|
||||||
const element = document.querySelector<HTMLDivElement>(`#status-list [data-index="${index}"] .focusable`);
|
if (!element) document.querySelector<HTMLDivElement>(selector)?.focus();
|
||||||
element?.focus();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,15 +31,16 @@ const ConversationsList: React.FC = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectChild = (index: number) => {
|
const selectChild = (index: number) => {
|
||||||
|
const selector = `#direct-list [data-index="${index}"] .focusable`;
|
||||||
|
const element = document.querySelector<HTMLDivElement>(selector);
|
||||||
|
|
||||||
|
if (element) element.focus();
|
||||||
|
|
||||||
ref.current?.scrollIntoView({
|
ref.current?.scrollIntoView({
|
||||||
index,
|
index,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
done: () => {
|
done: () => {
|
||||||
const element = document.querySelector<HTMLDivElement>(`#direct-list [data-index="${index}"] .focusable`);
|
if (!element) document.querySelector<HTMLDivElement>(selector)?.focus();
|
||||||
|
|
||||||
if (element) {
|
|
||||||
element.focus();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -83,15 +83,16 @@ const EventDiscussion: React.FC<IEventDiscussion> = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const _selectChild = (index: number) => {
|
const _selectChild = (index: number) => {
|
||||||
|
const selector = `#thread [data-index="${index}"] .focusable`;
|
||||||
|
const element = document.querySelector<HTMLDivElement>(selector);
|
||||||
|
|
||||||
|
if (element) element.focus();
|
||||||
|
|
||||||
scroller.current?.scrollIntoView({
|
scroller.current?.scrollIntoView({
|
||||||
index,
|
index,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
done: () => {
|
done: () => {
|
||||||
const element = document.querySelector<HTMLDivElement>(`#thread [data-index="${index}"] .focusable`);
|
if (!element) document.querySelector<HTMLDivElement>(selector)?.focus();
|
||||||
|
|
||||||
if (element) {
|
|
||||||
element.focus();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,16 +77,16 @@ const Notifications = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const _selectChild = (index: number) => {
|
const _selectChild = (index: number) => {
|
||||||
|
const selector = `[data-index="${index}"] .focusable`;
|
||||||
|
const element = document.querySelector<HTMLDivElement>(selector);
|
||||||
|
|
||||||
|
if (element) element.focus();
|
||||||
|
|
||||||
node.current?.scrollIntoView({
|
node.current?.scrollIntoView({
|
||||||
index,
|
index,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
done: () => {
|
done: () => {
|
||||||
const container = column.current;
|
if (!element) document.querySelector<HTMLDivElement>(selector)?.focus();
|
||||||
const element = container?.querySelector(`[data-index="${index}"] .focusable`);
|
|
||||||
|
|
||||||
if (element) {
|
|
||||||
(element as HTMLDivElement).focus();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -100,12 +100,16 @@ const SearchResults = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectChild = (index: number) => {
|
const selectChild = (index: number) => {
|
||||||
|
const selector = `#search-results [data-index="${index}"] .focusable`;
|
||||||
|
const element = document.querySelector<HTMLDivElement>(selector);
|
||||||
|
|
||||||
|
if (element) element.focus();
|
||||||
|
|
||||||
node.current?.scrollIntoView({
|
node.current?.scrollIntoView({
|
||||||
index,
|
index,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
done: () => {
|
done: () => {
|
||||||
const element = document.querySelector<HTMLDivElement>(`#search-results [data-index="${index}"] .focusable`);
|
if (!element) document.querySelector<HTMLDivElement>(selector)?.focus();
|
||||||
element?.focus();
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -233,11 +233,17 @@ const Thread: React.FC<IThread> = ({
|
||||||
|
|
||||||
const _selectChild = (index: number) => {
|
const _selectChild = (index: number) => {
|
||||||
if (!useWindowScroll) index = index + 1;
|
if (!useWindowScroll) index = index + 1;
|
||||||
|
|
||||||
|
const selector = `[data-index="${index}"] .focusable`;
|
||||||
|
const element = node.current?.querySelector<HTMLDivElement>(selector);
|
||||||
|
|
||||||
|
if (element) element.focus();
|
||||||
|
|
||||||
scroller.current?.scrollIntoView({
|
scroller.current?.scrollIntoView({
|
||||||
index,
|
index,
|
||||||
behavior: 'smooth',
|
behavior: 'smooth',
|
||||||
done: () => {
|
done: () => {
|
||||||
node.current?.querySelector<HTMLDivElement>(`[data-index="${index}"] .focusable`)?.focus();
|
if (!element) node.current?.querySelector<HTMLDivElement>(selector)?.focus();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -9054,10 +9054,10 @@ react-transition-group@^2.2.1:
|
||||||
prop-types "^15.6.2"
|
prop-types "^15.6.2"
|
||||||
react-lifecycles-compat "^3.0.4"
|
react-lifecycles-compat "^3.0.4"
|
||||||
|
|
||||||
react-virtuoso@^4.10.2:
|
react-virtuoso@^4.10.4:
|
||||||
version "4.10.2"
|
version "4.10.4"
|
||||||
resolved "https://registry.yarnpkg.com/react-virtuoso/-/react-virtuoso-4.10.2.tgz#a27308a3c4cfeb24722032acc0b6a46055c26967"
|
resolved "https://registry.yarnpkg.com/react-virtuoso/-/react-virtuoso-4.10.4.tgz#856ed415d7071db0c666ce84809bab8bb834f45c"
|
||||||
integrity sha512-os6n9QKeKRF+8mnQR/vGy/xrFf6vXIzuaAVL54q5k2st2d5QIEwI+KDKaflMUmMvnDbPxf68bs+CF5bY3YI7qA==
|
integrity sha512-G/gprhTbK+lzMxoo/iStcZxVEGph/cIhc3WANEpt92RuMw+LiCZOmBfKoeoZOHlm/iyftTrDJhGaTCpxyucnkQ==
|
||||||
|
|
||||||
react@^18.0.0:
|
react@^18.0.0:
|
||||||
version "18.2.0"
|
version "18.2.0"
|
||||||
|
|
Loading…
Reference in a new issue