Skip to content

Commit

Permalink
fix(button): prevent container keys ui flash
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Jul 23, 2021
1 parent e37161a commit f382763
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/docsearch-css/src/button.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

.DocSearch-Button-Keys {
display: flex;
width: calc(2 * 20px + 2 * 0.4em);
}

.DocSearch-Button-Key {
Expand Down
20 changes: 11 additions & 9 deletions packages/docsearch-react/src/DocSearchButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import React, { Fragment, useMemo } from 'react';

import { ControlKeyIcon } from './icons/ControlKeyIcon';
import { SearchIcon } from './icons/SearchIcon';
Expand Down Expand Up @@ -47,14 +47,16 @@ export const DocSearchButton = React.forwardRef<
<span className="DocSearch-Button-Placeholder">{buttonText}</span>
</span>

{key !== null && (
<span className="DocSearch-Button-Keys">
<span className="DocSearch-Button-Key">
{key === ACTION_KEY_DEFAULT ? <ControlKeyIcon /> : key}
</span>
<span className="DocSearch-Button-Key">K</span>
</span>
)}
<span className="DocSearch-Button-Keys">
{key !== null && (
<Fragment>
<span className="DocSearch-Button-Key">
{key === ACTION_KEY_DEFAULT ? <ControlKeyIcon /> : key}
</span>
<span className="DocSearch-Button-Key">K</span>
</Fragment>
)}
</span>
</button>
);
});

0 comments on commit f382763

Please sign in to comment.