Copy paste string to terminal leave a dangling empty area appearance
You need to enclose the non-printable characters properly in \[...\] block. This ensures that correct number of characters are counted while generating the prompt. 

I had the same problem and here's the PS1 that gave no issues so far : 

\[\e[30;47m\]$(parse_git_branch)\W\[\e[30;47m\]$\[\e[0m\]


That is my understanding of what I read on SO: 


  You should add \[ before any starting ANSI code and add \] after
  any ending ones.   Example:   in regular usage:  \033[32mThis is in
  green\033[0m   for PS0/1/2/4:     \[\033[32m\]This is in
  green\[\033[m\]  
  
  \[ is for start of a sequence of non-printable characters   \]
  is for end of a sequence of non-printable characters  
  
  Tip: for memorize it you can first add \[\] and then put your ANSI
  code between them:
    - \[start-ANSI-code\]
    - \[end-ANSI-code\]


https://stackoverflow.com/q/5947742/28938235#28938235

https://stackoverflow.com/q/17432993/

https://stackoverflow.com/q/20697195/20698168#20698168