'why is "align-items: center" not working in this context?

For some reason, I can't align this flex item <div>

enter image description here

When I hover over the property "align-items" these purple arrows appear. It seems like it is considering only half the container when applying the property. Other options like "flex-start" seem to behave "correctly".

Here is the code (I'm using React):

import { useState } from 'react';
import './App.css';

function App() {
  const [chatBoxOpened, setChatBoxOpened] = useState(false); 
  const [messages, setMessages] = useState(["this is the first message", "this is the second message"]);  


  const chatCollapsed = (
    <div className='chatBoxCollapsed'>
      <button onClick={() => {
        setChatBoxOpened(true); 
      }}>
        Chat
      </button>
    </div>
  )

  const chatOpened = (
    <div className='chatBoxOpened'>
      <div className='chatTitle'>
        <button onClick={() => {
          setChatBoxOpened(false); 
        }}>
          Chatting
        </button>
      </div>
      <div className='chatMessagesBox'>
        <div className='chatMessages'>
          {messages.forEach(message => {
            <div className='chatMessageWrapper'>
              <div className='chatMessage'>
                {message}
              </div>
            </div>
          })}
        </div>
        <div className='chatInputSectionWrapper'>
          <div className='chatInputWrapper'>
            <input className='chatInput' placeholder='type your message'/>
            <button className='chatInputButton'>
              Send
            </button>
          </div>
        </div>
      </div>
    </div>
  )

  return (
    <div className="App">
      <h1>
        This is a title
      </h1>
      <div>
        {chatBoxOpened ? chatOpened : chatCollapsed}
      </div>
    </div>
  );
}

export default App;

And the stylesheet linked:

.App {
  text-align: center;
  height: 100%;
}

.App-logo {
  height: 40vmin;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  .App-logo {
    animation: App-logo-spin infinite 20s linear;
  }
}

.App-header {
  background-color: #282c34;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: calc(10px + 2vmin);
  color: white;
}

.App-link {
  color: #61dafb;
}

@keyframes App-logo-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

html, body {
  height: 100%;
}

.chatBoxCollapsed {
  font-family: sans-serif;
  text-align: left;
  position: absolute; 
  bottom: 0; 
  right: 0; 
  width: 200px;
  height: 30px;
  margin-right: 40px; 
  padding: 10px; 
}
.chatBoxCollapsed > button {
  height: 100%;
  width: 100%;
  text-align: left;
}

.chatBoxOpened {
  position: absolute; 
  bottom: 0; 
  right: 0;
  height: 300px;
  width: 200px;
  margin-right: 40px;
  padding: 10px; 
}
.chatTitle {
  font-family: sans-serif;
  height: 30px;
  background-color: gray;
}
.chatTitle > button {
  height: 100%;
  width: 100%;
  text-align: left;
}
.chatMessagesBox {
  height: 100%;  
}
.chatMessages {
  height: 80%;
}

.chatInputSectionWrapper {
  display: flex;
  height: 20%; 
  align-items: center;
  justify-content: center;
}
.chatInputWrapper {
  display: center; 
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source