Skip to content

Commit

Permalink
[Logs UI] Fix column reordering in settings page (#58104)
Browse files Browse the repository at this point in the history
* Ensure only one element has scroll

Apparently having multiple elements with scroll confuses the
`react-beautiful-dnd` mechanism to determine the position of the
elements. Adding `overflowY` to the app root fixes it.

* Fix upper bound check for log column reordering

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
Alejandro Fernández and elasticmachine committed Feb 20, 2020
1 parent dfd1959 commit 5953e62
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions x-pack/plugins/infra/public/apps/start_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export async function startApp(
// expected.
element.style.height = '100%';
element.style.display = 'flex';
element.style.overflowY = 'hidden'; // Prevent having scroll within a container having scroll. It messes up with drag-n-drop elements
element.className += ` ${CONTAINER_CLASSNAME}`;

ReactDOM.render(<App />, element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const useLogColumnsConfigurationFormState = ({

const moveLogColumn = useCallback(
(sourceIndex, destinationIndex) => {
if (destinationIndex >= 0 && sourceIndex < formState.logColumns.length - 1) {
if (destinationIndex >= 0 && sourceIndex <= formState.logColumns.length - 1) {
const newLogColumns = [...formState.logColumns];
newLogColumns.splice(destinationIndex, 0, newLogColumns.splice(sourceIndex, 1)[0]);
setFormStateChanges(changes => ({
Expand Down

0 comments on commit 5953e62

Please sign in to comment.