# glossaries-extra discardperiod and abbreviation long form

When using the discardperiod functionality from glossaries-extra the following period gets unduly discarded when an explicitly long form is used:

\documentclass{article}

\usepackage[
abbreviations,
shortcuts=abbr,
]{glossaries-extra}

\glssetcategoryattribute{abbreviation}{retainfirstuseperiod}{true}

\newabbreviation{dr}{Dr.}{Doctor}

\begin{document}

% This is OK.
\ab{dr}. \ab{dr}.

% This is still OK.
\as{dr}.

% This period gets unduly discarded.
\al{dr}.

\end{document}


Anyone happens to know a way to get this case correctly?

I think I could come up with something reasonable, even if this one was trickier than I hoped for.

\documentclass{article}

\usepackage[
abbreviations,
shortcuts=abbr,
]{glossaries-extra}

\glssetcategoryattribute{abbreviation}{retainfirstuseperiod}{true}

\newtoggle{glsenddot}
\NewDocumentCommand{\glsdot}{}{\global\toggletrue{glsenddot}.\@}
\makeatletter
\renewcommand*{\glsxtrifperiod}[1]{%
\iftoggle{glsenddot}
{%
\global\togglefalse{glsenddot}%
\new@ifnextchar.{\@firstoftwo{#1}}%
}
{\@secondoftwo{#1}}%
}
\makeatother

\newabbreviation{dr}{Dr\glsdot}{Doctor}
\newabbreviation{abc}{ABC}{Aaaa Bbbb Cccc}

\begin{document}

% This is OK.
\ab{dr}.  \ab{abc}. \ab{abc}. \ab{dr}.

% This is still OK.
\as{dr}.

% This period is now in place.
\al{dr}.

\ab{abc}.

\end{document}