From Bulbapedia, the community-driven Pokémon encyclopedia.
The Choice item lock glitch is present in the core series Generation V, VI, and VII games. It has different effects in each generation.
It restricts the moves a Pokémon can use even when it is no longer holding a Choice item (the Choice Band, Choice Specs, or Choice Scarf).
If a Pokémon is already locked into a move due to a Choice item, if the held Choice item is removed while the effect of the Pokémon's held item is negated (by Klutz, Embargo, or Magic Room), the Pokémon will remain locked into the move. A Pokémon cannot become locked into a move via a held Choice item while its item is negated; this only occurs if it was locked into a move before its item had its effect negated.
When the Pokémon's held item regains its effect (e.g. Magic Room wears off), as long as the Pokémon has a held item—regardless of what the held item is—the Pokémon cannot select moves other than the one it is locked into; if it attempts to select another move, the message "The <HELD ITEM> only allows the use of <MOVE>!" will be displayed ("The <HELD ITEM> allows the use of only <MOVE>!" in Generation V). If the held item in question is an Assault Vest, it continues to have its usual effect in addition to the lock, and if the Pokémon had locked into a status move, it will be forced to use Struggle.
In Generation V, this also applies if it has no held item, with "None" being displayed in place of the name of the held item. In Generation VI and VII, this glitch does not affect the Pokémon's ability to choose moves while it has no held item.
In Generation VII, if a Pokémon is locked into a move by a Choice item, but does not have a held item or its held item's effect is negated, it is free to choose any of its moves. However, if the Pokémon would use a move other than the move it is locked into (including by means such as Dancer), that move fails, even if it does not have a held item.
In Pokémon Sun and Moon only, moves other than the move it is locked into fail even if the effect of the Pokémon's held item is negated. In Pokémon Ultra Sun and Ultra Moon, if the Pokémon is affected by an effect that negates the effect of its held item, moves will never fail this way, even if it does not have a held item.
This glitch was resolved in Generation VIII.
If a Pokémon is locked into a move due to a Choice item or Gorilla Tactics, but the effect of that held item or Ability is suppressed, the Pokémon can freely select and successfully use any of its moves. If the Pokémon later becomes affected by a Choice item or Gorilla Tactics again (even if it is a different effect to the original effect that locked the Pokémon into a move), it will once again be locked into that original move.