Skip to content

Commit

Permalink
fix: 🐛 block component trigger button
Browse files Browse the repository at this point in the history
  • Loading branch information
Saul-Mirone committed Aug 26, 2023
1 parent 090804b commit b28d689
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion e2e/src/code-block/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ milkdown-code-block .list-wrapper {
background: antiquewhite;
border-radius: 16px;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30);
width: 220px;
}

milkdown-code-block .language-list {
Expand Down Expand Up @@ -98,7 +99,7 @@ milkdown-code-block .search-box {
}

milkdown-code-block .search-box .search-input {
flex: 1;
width: 100%;
}

milkdown-code-block .search-box .search-icon svg {
Expand Down
8 changes: 4 additions & 4 deletions packages/components/src/code-block/view/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export const codeComponent: Component<CodeComponentProps> = ({

useEffect(() => {
const clickHandler = (e: MouseEvent) => {
if (e.target === triggerRef.current)
const target = e.target as HTMLElement

if (triggerRef.current && triggerRef.current.contains(target))
return

const picker = pickerRef.current
Expand All @@ -61,8 +63,6 @@ export const codeComponent: Component<CodeComponentProps> = ({
if (picker.dataset.expanded !== 'true')
return

const target = e.target as HTMLElement

if (!picker.contains(target))
setShowPicker(false)
}
Expand Down Expand Up @@ -170,7 +170,7 @@ export const codeComponent: Component<CodeComponentProps> = ({
oninput=${changeFilter}
onkeydown=${onSearchKeydown}
/>
<div class="clear-icon" onmousedown=${onClear}>
<div class=${clsx('clear-icon', filter.length === 0 && 'hidden')} onmousedown=${onClear}>
${config?.clearSearchIcon?.()}
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions packages/components/src/code-block/view/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ export const style = css`
:host .search-box .clear-icon {
cursor: pointer;
}
:host .hidden {
display: none;
}
`

0 comments on commit b28d689

Please sign in to comment.