-
Notifications
You must be signed in to change notification settings - Fork 45
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
refactor(select): reworked selectMobile component with apply feature #599
Conversation
🦋 Changeset detectedLatest commit: 4964d33 The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Собрана новая демка. |
Собрана новая демка. |
Тут есть нюанс, что по дефолту мобильный селект должен работать с "подтверждением". |
Тут выбор работает "на заднем плане", а кнопки не работают const OPTIONS = Array.from({ length: 100 }).map((_, i) => ({
key: i.toString(),
content: `Neptunium ${i}`,
}));
render(() => {
const [selected, setSelected] = React.useState([]);
const handleChange = ({ selectedMultiple }) => {
setSelected(selectedMultiple.map((option) => option.key));
};
return (
<div style={{ width: document.body.clientWidth < 450 ? '100%' : 320 }}>
<SelectModalMobile
multiple
allowUnselect={true}
options={OPTIONS}
placeholder='С подтверждением'
Option={BaseOption}
block={true}
selected={selected}
onChange={handleChange}
/>
</div>
);
}); |
Еще есть SelectModalMobile, нужно чекнуть, что в нем все будет работать корректно |
Сейчас список открывается на 5.5 опций, как в десктопе. Это поведение нужно сделать отключаемым для мобилки. const OPTIONS = [
{ key: '1', content: 'Neptunium' },
{ key: '2', content: 'Plutonium' },
{ key: '3', content: 'Americium' },
{ key: '4', content: 'Curium' },
{ key: '5', content: 'Berkelium' },
{ key: '6', content: 'Californium' },
{ key: '7', content: 'Einsteinium' },
{ key: '8', content: 'Fermium' },
];
render(() => {
const [selected, setSelected] = React.useState([]);
const handleChange = ({ selectedMultiple }) => {
setSelected(selectedMultiple.map((option) => option.key));
};
return (
<div style={{ width: document.body.clientWidth < 450 ? '100%' : 320 }}>
<SelectMobile
allowUnselect={true}
options={OPTIONS}
placeholder='С подтверждением'
Option={BaseOption}
block={true}
{...useSelectWithApply({
options: OPTIONS,
selected,
onChange: handleChange,
})}
/>
</div>
);
}); |
packages/select/src/presets/useSelectWithApply/options-list-with-apply/index.module.css
Outdated
Show resolved
Hide resolved
…-mobile Убрал компоненты в base-select-mobile, отправил хук useSelectWithApply внутрь компонента, теперь на мобилках правильно работает подтверждение применения с множественным выбором
Собрана новая демка. |
…ctor/select-mobile
71203ec
to
f85f30c
Compare
Собрана новая демка. |
Собрана новая демка. |
…onents into refactor/select-mobile
Собрана новая демка. |
Собрана новая демка. |
Собрана новая демка. |
Собрана новая демка. |
Никита, ты герой! 🔥 С BottomSheet вроде все ок работает. С модалкой есть пару проблем:
|
@@ -46,6 +46,8 @@ export const VirtualOptionsList = ({ | |||
const [visibleOptionsInvalidateKey, setVisibleOptionsInvalidateKey] = useState(0); | |||
const prevHighlightedIndex = usePrevious(highlightedIndex) || -1; | |||
|
|||
const numberOfVisibleOptions = visibleOptionsFromProps === 0 ? 12 : visibleOptionsFromProps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Screencast.from.2023-03-31.17-22-42.webm
С виртуальным списком что-то не то, два скролла сейчас
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Насчет VirtualOptionsList нет идей что можно сделать чтобы пофиксить дабл скролл, такое поведение только с BottomSheet, с модалкой вроде ок
Собрана новая демка. |
Собрана новая демка. |
Собрана новая демка. |
Собрана новая демка. |
Опишите проблему
Невозможно использовать хук useSelectWithApply вместе с компонентом SelectMobile, также нельзя контролировать состояние выбора снаружи компонента