Feature/support dropdownmenu position fixed (#37669)

* fix(reactstrap): Add positionFixed property to DropdownMenu of reactstrap

* style(reactstrap): Format some test code

* fix(reactstrap): Fix the component unit tests

* style(reactstrap): Format code style
This commit is contained in:
devalon
2019-08-21 04:15:16 +09:00
committed by Sheetal Nandi
parent 2256544791
commit fa2fc8c39c
5 changed files with 67 additions and 0 deletions

View File

@@ -9,6 +9,7 @@
// Prabodh Tiwari <https://github.com/prabodht>
// Georg Steinmetz <https://github.com/georg94>
// Kyle Tsang <https://github.com/kyletsang>
// Hayato Shimokawa <https://github.com/ichiwa>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9

View File

@@ -11,6 +11,7 @@ export interface DropdownMenuProps extends React.HTMLAttributes<HTMLElement> {
flip?: boolean;
modifiers?: Popper.Modifiers;
persist?: boolean;
positionFixed?: boolean;
}
declare class DropdownMenu<T = {[key: string]: any}> extends React.Component<DropdownMenuProps> {}

View File

@@ -4563,3 +4563,35 @@ function Example128() {
</Form>
);
}
class Example129 extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.toggle = this.toggle.bind(this);
this.state = {
dropdownOpen: false,
};
}
toggle() {
this.setState({
dropdownOpen: !this.state.dropdownOpen,
});
}
render() {
return (
<Dropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}>
<DropdownToggle caret>Dropdown</DropdownToggle>
<DropdownMenu persist positionFixed>
<DropdownItem header>Header</DropdownItem>
<DropdownItem disabled>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem divider />
<DropdownItem>Another Action</DropdownItem>
</DropdownMenu>
</Dropdown>
);
}
}

View File

@@ -10,6 +10,7 @@ export type DropdownMenuProps<T = {}> = React.HTMLAttributes<HTMLElement> & {
flip?: boolean;
modifiers?: Popper.Modifiers;
persist?: boolean;
positionFixed?: boolean;
} & T;
declare class DropdownMenu<T = {[key: string]: any}> extends React.Component<DropdownMenuProps<T>> {}

View File

@@ -4357,3 +4357,35 @@ function Example126() {
</div>
);
}
class Example127 extends React.Component<any, any> {
constructor(props: any) {
super(props);
this.toggle = this.toggle.bind(this);
this.state = {
dropdownOpen: false,
};
}
toggle() {
this.setState({
dropdownOpen: !this.state.dropdownOpen,
});
}
render() {
return (
<Dropdown isOpen={this.state.dropdownOpen} toggle={this.toggle}>
<DropdownToggle caret>Dropdown</DropdownToggle>
<DropdownMenu persist positionFixed>
<DropdownItem header>Header</DropdownItem>
<DropdownItem disabled>Action</DropdownItem>
<DropdownItem>Another Action</DropdownItem>
<DropdownItem divider />
<DropdownItem>Another Action</DropdownItem>
</DropdownMenu>
</Dropdown>
);
}
}