fix: fix select rtl (#23235)

* fix: fix select rtl

* fix lint

Co-Authored-By: Amumu <yoyo837@hotmail.com>

Co-authored-by: Amumu <yoyo837@hotmail.com>
This commit is contained in:
xrkffgg 2020-04-14 16:42:39 +08:00 committed by GitHub
parent c338569cff
commit 1855fef437
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -28,8 +28,7 @@
// ========================== Popup ==========================
&-dropdown {
&-rtl {
direction: ltr;
text-align: right;
direction: rtl;
}
}

View File

@ -40,7 +40,7 @@ function initDocSearch(locale: string) {
transformData(hits: { url: string }[]) {
hits.forEach(hit => {
hit.url = hit.url.replace('ant.design', window.location.host);
hit.url = hit.url.replace('https:', window.location.protocol)
hit.url = hit.url.replace('https:', window.location.protocol);
});
return hits;
},
@ -131,6 +131,17 @@ class Header extends React.Component<HeaderProps, HeaderState> {
return 'LTR';
};
getDropdownStyle = (): React.CSSProperties => {
const { direction } = this.context;
if (direction === 'rtl') {
return {
direction: 'ltr',
textAlign: 'right',
};
}
return {};
};
onMenuVisibleChange = (visible: boolean) => {
this.setState({
menuVisible: visible,
@ -233,6 +244,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
size="small"
defaultValue={antdVersion}
onChange={this.handleVersionChange}
dropdownStyle={this.getDropdownStyle()}
getPopupContainer={trigger => trigger.parentNode}
>
{versionOptions}