Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scrollbar bug with iOS 13+ #581

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/components/hv-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as Render from 'hyperview/src/services/render';
import {
RefreshControl as DefaultRefreshControl,
FlatList,
Platform,
} from 'react-native';
import React, { PureComponent } from 'react';
import { DOMParser } from 'xmldom-instawork';
Expand Down Expand Up @@ -106,6 +107,13 @@ export default class HvList extends PureComponent<HvComponentProps, State> {
const showScrollIndicator =
this.props.element.getAttribute('shows-scroll-indicator') !== 'false';

// Fix scrollbar rendering issue in iOS 13+
// https://github.com/facebook/react-native/issues/26610#issuecomment-539843444
const scrollIndicatorInsets =
Platform.OS === 'ios' && parseInt(Platform.Version, 10) >= 13
? { right: 1 }
: undefined;

const listProps = {
data: this.getItems(),
horizontal,
Expand All @@ -118,6 +126,7 @@ export default class HvList extends PureComponent<HvComponentProps, State> {
this.props.onUpdate,
this.props.options,
),
scrollIndicatorInsets,
showsHorizontalScrollIndicator: horizontal && showScrollIndicator,
showsVerticalScrollIndicator: !horizontal && showScrollIndicator,
style,
Expand Down
9 changes: 9 additions & 0 deletions src/components/hv-section-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import * as Namespaces from 'hyperview/src/services/namespaces';
import * as Render from 'hyperview/src/services/render';
import {
RefreshControl as DefaultRefreshControl,
Platform,
SectionList,
} from 'react-native';

Expand Down Expand Up @@ -138,6 +139,13 @@ export default class HvSectionList extends PureComponent<
});
}

// Fix scrollbar rendering issue in iOS 13+
// https://github.com/facebook/react-native/issues/26610#issuecomment-539843444
const scrollIndicatorInsets =
Platform.OS === 'ios' && parseInt(Platform.Version, 10) >= 13
? { right: 1 }
: undefined;

const listProps = {
keyExtractor: item => item.getAttribute('key'),
renderItem: ({ item }) =>
Expand All @@ -154,6 +162,7 @@ export default class HvSectionList extends PureComponent<
this.props.onUpdate,
this.props.options,
),
scrollIndicatorInsets,
sections,
stickySectionHeadersEnabled: this.getStickySectionHeadersEnabled(),
style,
Expand Down