forked from Gitlink/forgeplus-react
新建分支后,下拉选项未及时更新
This commit is contained in:
parent
078a453dcf
commit
c2f0462811
|
@ -41,6 +41,7 @@ export default (({ projectsId , branch , owner , changeBranch , branchList , tag
|
|||
const menu = (
|
||||
<div ref={refFa}>
|
||||
<SelectOverlay
|
||||
visible={visible}
|
||||
changeBranch={ChangeB}
|
||||
tagflag={tagflag}
|
||||
projectsId={projectsId}
|
||||
|
|
|
@ -2,7 +2,7 @@ import React , { useState , useEffect } from 'react';
|
|||
import { Input , Spin , Menu } from 'antd';
|
||||
import { getBranch , getTag } from '../GetData/getData';
|
||||
|
||||
function SelectOverlay({ changeBranch , tagflag , branchList , projectsId , owner }) {
|
||||
function SelectOverlay({ changeBranch , tagflag , branchList , projectsId , owner , visible }) {
|
||||
const [ inputValue , setInputValue] = useState(undefined);
|
||||
const [ nav , setNav ] = useState(0);
|
||||
const [ isSpin , setIsSpin ] = useState(true);
|
||||
|
@ -11,6 +11,14 @@ function SelectOverlay({ changeBranch , tagflag , branchList , projectsId , owne
|
|||
const [ datas , setDatas ] = useState(undefined);
|
||||
const [ keys ,setKeys] = useState("branch");
|
||||
|
||||
useEffect(()=>{
|
||||
if(visible){
|
||||
setKeys("branch");
|
||||
getBranchs(projectsId,owner);
|
||||
setIsSpin(true);
|
||||
}
|
||||
},[visible])
|
||||
|
||||
useEffect(()=>{
|
||||
if(branchList){
|
||||
setData(branchList);
|
||||
|
@ -68,12 +76,16 @@ function SelectOverlay({ changeBranch , tagflag , branchList , projectsId , owne
|
|||
<Spin spinning={isSpin}>
|
||||
<ul className="OptionsUl" id="ul-btn">
|
||||
{
|
||||
datas && datas.length>0 ?
|
||||
datas && datas.length>0 &&
|
||||
datas.map((item,key)=>{
|
||||
return(
|
||||
<li key={key} onClick={()=>chooseitem(item.name)}><a className="task-hide ulALink">{item.name}</a></li>
|
||||
)
|
||||
}):
|
||||
})
|
||||
|
||||
}
|
||||
{
|
||||
datas && datas.length === 0 &&
|
||||
<p className="listTips">暂无{inputValue}{nav === 0 ?"分支":"标签"}~</p>
|
||||
}
|
||||
</ul>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
max-height: 300px;
|
||||
}
|
||||
.OptionsUl{
|
||||
min-height: 50px;
|
||||
max-height: 220px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue