fix lint format
This commit is contained in:
@@ -50,7 +50,7 @@ export const CommandMenuContainer = ({
|
|||||||
>();
|
>();
|
||||||
const [needCheckIntoView, setNeedCheckIntoView] = useState<boolean>(false);
|
const [needCheckIntoView, setNeedCheckIntoView] = useState<boolean>(false);
|
||||||
|
|
||||||
const current_category = useMemo(
|
const currentCategory = useMemo(
|
||||||
() =>
|
() =>
|
||||||
(Object.entries(menuItemsMap).find(
|
(Object.entries(menuItemsMap).find(
|
||||||
([, infos]) =>
|
([, infos]) =>
|
||||||
@@ -62,23 +62,23 @@ export const CommandMenuContainer = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (needCheckIntoView) {
|
if (needCheckIntoView) {
|
||||||
if (currentItem && menuRef.current) {
|
if (currentItem && menuRef.current) {
|
||||||
const item_ele =
|
const itemEle =
|
||||||
menuRef.current.querySelector<HTMLButtonElement>(
|
menuRef.current.querySelector<HTMLButtonElement>(
|
||||||
`.item-${currentItem}`
|
`.item-${currentItem}`
|
||||||
);
|
);
|
||||||
const scroll_ele =
|
const scrollEle =
|
||||||
menuRef.current.querySelector<HTMLButtonElement>(
|
menuRef.current.querySelector<HTMLButtonElement>(
|
||||||
`.${commonListContainer}`
|
`.${commonListContainer}`
|
||||||
);
|
);
|
||||||
if (item_ele) {
|
if (itemEle) {
|
||||||
const itemRect = domToRect(item_ele);
|
const itemRect = domToRect(itemEle);
|
||||||
const scrollRect = domToRect(scroll_ele);
|
const scrollRect = domToRect(scrollEle);
|
||||||
if (
|
if (
|
||||||
itemRect.top < scrollRect.top ||
|
itemRect.top < scrollRect.top ||
|
||||||
itemRect.bottom > scrollRect.bottom
|
itemRect.bottom > scrollRect.bottom
|
||||||
) {
|
) {
|
||||||
// IMP: may be do it with self function
|
// IMP: may be do it with self function
|
||||||
item_ele.scrollIntoView({
|
itemEle.scrollIntoView({
|
||||||
block: 'nearest',
|
block: 'nearest',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -195,17 +195,17 @@ export const CommandMenuContainer = ({
|
|||||||
...(blocks || []),
|
...(blocks || []),
|
||||||
...Object.entries(menuItemsMap).flatMap(
|
...Object.entries(menuItemsMap).flatMap(
|
||||||
([category, items], idx, all) => {
|
([category, items], idx, all) => {
|
||||||
let render_separator = false;
|
let renderSeparator = false;
|
||||||
const lines: CommonListItem[] = items
|
const lines: CommonListItem[] = items
|
||||||
.filter(item => types.includes(item.type))
|
.filter(item => types.includes(item.type))
|
||||||
.map(item => {
|
.map(item => {
|
||||||
const { text, type, icon } = item;
|
const { text, type, icon } = item;
|
||||||
render_separator = true;
|
renderSeparator = true;
|
||||||
return {
|
return {
|
||||||
content: { id: type, content: text, icon },
|
content: { id: type, content: text, icon },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
if (render_separator && idx !== all.length - 1) {
|
if (renderSeparator && idx !== all.length - 1) {
|
||||||
lines.push({ divider: category });
|
lines.push({ divider: category });
|
||||||
}
|
}
|
||||||
return lines;
|
return lines;
|
||||||
@@ -223,7 +223,7 @@ export const CommandMenuContainer = ({
|
|||||||
>
|
>
|
||||||
<div className={styles('contentContainer')}>
|
<div className={styles('contentContainer')}>
|
||||||
<MenuCategories
|
<MenuCategories
|
||||||
currentCategories={current_category}
|
currentCategories={currentCategory}
|
||||||
onSetCategories={handleSetCategories}
|
onSetCategories={handleSetCategories}
|
||||||
categories={categories}
|
categories={categories}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user