/
githubmirror
/
react-beautiful-dnd
Обзор
Документация
Войти
/
githubmirror
/
react-beautiful-dnd
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/state/middleware/focus.js
42 строки
1 KB
Alex Reardon
12.0 (#1487)
29 окт 2019, 01:40
Не верифицирован
29 окт 2019, 01:40
24a8e60
Код
Авторство
О чём код?
// @flow import type { DropResult } from '../../types'; import type { Action, Dispatch } from '../store-types'; import type { FocusMarshal } from '../../view/use-focus-marshal/focus-marshal-types'; export default (marshal: FocusMarshal) => { let isWatching: boolean = false; return () => (next: Dispatch) => (action: Action): any => { if (action.type === 'INITIAL_PUBLISH') { isWatching = true; marshal.tryRecordFocus(action.payload.critical.draggable.id); next(action); marshal.tryRestoreFocusRecorded(); return; } next(action); if (!isWatching) { return; } if (action.type === 'FLUSH') { isWatching = false; marshal.tryRestoreFocusRecorded(); return; } if (action.type === 'DROP_COMPLETE') { isWatching = false; const result: DropResult = action.payload.completed.result; // give focus to the combine target when combining if (result.combine) { marshal.tryShiftRecord(result.draggableId, result.combine.draggableId); } marshal.tryRestoreFocusRecorded(); } }; };